Search code examples
outlookvstooutlook-addinoffice-addinsscaling

VSTO Outlook: how to know which scaling factor is using Outlook


Is there any way in VSTO to know what is the scaling factor that outlook applies to its font in the UI every time user changes screen resolution or scale from display settings in the OS?

I see that when you change screen resolution or scale from the OS the custom task pane height remains the same, it is not being increasing or decreasing accordingly. So i thought to get the scaling factor and then apply it manually to the custom task pane height.


Solution

  • The Outlook object model doesn't provide such information. You can use the GetDpiForWindow function which returns the dots per inch (dpi) value for the specified window. Based on that information you may calculate the scaling factor. You are free to use any Windows API or .Net based mechanisms for calculating the scaling factor, for example, see How to get scaling factor for each monitor, e.g. 1, 1.25, 1.5 for more information.