VSTO Outlook: Setting custom task pane height based on the screen resolution - outlook

I have an VSTO Outlook Add-in which shows a custom task pane (ctp). This ctp embeds a usercontrol which in turn contains an elementhost. The elementhost hosts an WPF user control.
At Add-in startup I create the ctp and I set it a fixed height, e.g. 120 points. I have noticed that depending on the screen resolution the ctp height gets smaller or bigger.
So I would like to know if there is a way to set the ctp height according to the current screen resolution so it does not get smaller or bigger.
For example some formula:
ctp.Height = Default_Height * Y_Scaling_Factor
I have tried setting the autoscalemode to font and dpi and it does not work.

You need to set the AutoScaleMode property to None if you don't want to get the container scaled according to the screen resolution.
The AutoScaleMode property specifies the current automatic scaling mode of this control. Scaling by Font is useful if you want to have a control or form stretch or shrink according to the size of the fonts in the operating system, and should be used when the absolute size of the control or form does not matter. Scaling by Dpi is useful when you want to size a control or form relative to the screen. For example, you may want to use dots per inch (DPI) scaling on a control displaying a chart or other graphic so that it always occupies a certain percentage of the screen.
For more information about automatic scaling, see Automatic Scaling in Windows Forms.
Also you may take a look at the AutoSize and AutoSizeMode properties that resize the form according to the setting of AutoSizeMode.

Related

VSTO Outlook: Custom Task Pane height

Why the custom task pane height is set in points?
What do points mean? If I want to set the custom pane height to work with all the display resolutions, how do I need to set this? using some kind of formula? For example I set as below in a screen resolution of 3024x1890 and it is shown correctly:
ctp.Height = 160;
However when I visualize it in a screen resolution of 1920x1080 the custom task pane is not shown correctly, I mean, height is bigger that the one in 3024x1890.
Pixels and points are static measurements - they don't change based on other factors: 1 pixel is always 1 pixel and is the smallest piece of a screen that can display colors. 1 point is always 1 point and is an abstract unit, only having meaning when referenced in relation to other points.
You need to set up the AutoScaleMode of the UserForm to the Dpi which specifies the different types of automatic scaling modes supported by Windows Forms. Then you can try to use dock and anchor properties to auto resize and adjust controls. That may work only for standalone applications and not in Outlook (depends on Outlook version). So, additionally you need to detect the DPI level and set up the UI accordingly.
Take a look at the following pages for more information about scaling in Windows:
Windows Forms DPI scaling
Creating a DPI-Aware Application
Automatic scaling in Windows Forms

CCM_DPISCALE common control message

I've been updating an existing Win32 app to be DPI aware. Following various guides on MSDN and other sites, I manually scale my coordinates and font sizes according to the current monitor DPI.
I just stumbled upon this message: CCM_DPISCALE. The docs say:
Enables automatic high dots per inch (dpi) scaling in Tree-View
controls, List-View controls, ComboBoxEx controls, Header controls,
Buttons, Toolbar controls, Animation controls, and Image Lists
But what does it actually do? I try sending the message to my control like so:
SendMessage(hWnd, CCM_DPISCALE, (WPARAM) TRUE, 0);
But it has no discernible effect on font, size, layout - anything, at any DPI.
I am using Comclt32.dll version 6.0, as per the documentation.
The only reference I can find to this message when Googling it is that MSDN page, and a link from the LVCOLUMNA documentation.
What is this message actually supposed to do?
I figured out at least a small part of what this does.
In a ListView control, if columns are created with fixed width (LVCFMT_FIXED_WIDTH) and as long as you don't specify LVCFMT_NO_DPI_SCALE, CCM_DPISCALE will scale the column width according to the current DPI.
If you have a grouped LVS_REPORT style ListView, and the group header contains an image (LVGF_TITLEIMAGE) that image will also be scaled (but not the group text (LVGF_HEADER))
I didn't test if this scaling is per monitor or not, and I didn't find anything else that this message does (although as per my question, it is documented to effect multiple controls). I am interested in finding out what else this message does!

Visual Studio / MFC: BMP fills Picture Control on desktop, but is too small on my laptop

I have a number of dialogs with Picture Controls. On my Win10 desktop, the BMP correctly fills the entire picture control, but on my Win10 laptop the BMP only fills about 2/3 of the picture control.
If I change Windows 10 "Scale and layout" setting from say 100% to 125% on both my desktop and laptop, then the dialog and BMP both get bigger/smaller, but the same problem exists: the BMP is significantly smaller than the control on my laptop.
In the Picture Control properties, Image is set to an IDB bitmap resource, and Type=Bitmap.
Is there an easy fix for this?
If you look here:
https://msdn.microsoft.com/en-us/library/windows/desktop/bb760773(v=vs.85).aspx
You will see the following quote:
SS_REALSIZEIMAGE is always used in conjunction with SS_ICON.
You need to change your resource setting because yours is not an icon. That article also states:
SS_REALSIZECONTROL
Adjusts the bitmap to fit the size of the static control. For example, changing the locale can change the system font, and thus controls might be resized. If a static control had a bitmap, the bitmap would no longer fit the control. This style bit dictates automatic redimensioning of bitmaps to fit their controls.
If SS_CENTERIMAGE is specified, the bitmap or icon is centered (and clipped if needed). If SS_CENTERIMAGE is not specified, the bitmap or icon is stretched or shrunk.
Note that the redimensioning in the two axes are independent, and the result may have a changed aspect ratio.

How to customize the screen size of ARC-Welder?

I would like to change the screen size of the ARC-Welder chrome-extention to a 7inch screen - displayed on my pc - to test an app on different screen sizes.
Can this be done using for example the meta-data input?
Similar to a question that I asked recently but I think shares the same answer. It seems that there are few choices when it comes to form factor, and based on the answer to my question I think that you can only use the three form factor presets for now.
(from #Elijah Taylor)
The size of the window is not configurable per activity*, but the orientation is. The two options in ARC Welder that control the window are:
Orientation: This is either landscape or portrait, which will be the default orientation for your app. However, if you set a screenOrientation on your Android activity, this can override the orientation per activity, with the window rotating to compensate. There is a performance cost to rotating this way because the plugin will be rotated via CSS.
Form Factor: This is one of phone, tablet, or maximized. This controls the overall size of your app globally.
but for Chrome 42 and up you can use the metadata {"resize": "reconfigure"} to allow arbitrary user resizing. Your app must be able to relayout with a variety of aspect ratios and resolutions in this mode.
My question at:Android ARC app for chrome, set size of windows for different Activities/Layouts
You can Use this MetaData :
{
"resize":"reconfigure"
}
just thought i'd mention that there is also "formFactor": "fullscreen" if want to test full screen it also works with "resize":"reconfigure"

how to make a bitmap to fit to the static picture control of a property sheet?

I am having a property sheet and added three pages.In the first page I added a picture control and in the properties of that picture control for "Image" property I am setting a bitmap.And was able to load very successfully.But,the problem here I faced when I run my exe then I am getting bitmap on the page header(which is some kind of banner for the page.)But what I noticed is there is some gap between the banner bitmap and the frame edge (which is occurring at the right top corner). And when I ran my xxx.exe on a Japanese machine then I had observed like the sheet is somewhat stretched and banner bitmap is not stretched completely till the edge of the sheet (top right corner)for Instance if we take a dialog on load a bitmap on it then we can observe that it is entirely got stretched till the edge.
So how can we avoid this issue like whatever the operating system it is and whatever the resolution it might be that banner should get stretched till the edge of the sheet.The gap has to be removed.
I am not loading the bitmap dynamically (setting in the properties.)
Can anyone please help me ti achieve this
The reason you get different results on different systems is that dialogs and controls are sized using "dialog units" which are based on the average size of the font, rather than an absolute number of pixels.
By default a static image control will resize itself to the size of the bitmap it's displaying. So if the dialog itself ends up bigger than normal (because the font is physically bigger), the picture control will appear to have shrunk, leaving a gap.
You could try setting the SS_REALSIZECONTROL style on the static control. The normal behavior of the static control (when displaying a picture) is to resize itself to the size of the bitmap, however the SS_REALSIZECONTROL style overrides that behavior and instead causes the bitmap to be resized to the size of the control. However the results of that may be less than optimal (e.g. the aspect ratio will probably be wrong), so instead you may want to look into scaling the bitmap yourself.

Resources