0

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.

Willy
  • 9,848
  • 22
  • 141
  • 284

1 Answers1

1

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:

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • Mine is a WPF, not winforms. Rather than set a fixed height for task pane, now I am trying to adjust automatically the height of the task pane to the height of the user control, but I don't know how I can do this. See my code here: https://learn.microsoft.com/en-us/answers/questions/943174/vsto-outlook-autosize-custom-task-pane-height-to-t.html Do you know how can I do this, please? I have spent so many days and I am not be able to do it. – Willy Jul 27 '22 at 07:44