outlookvstooutlook-addinoffice-addinscustomtaskpane

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.


Solution

  • 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: