Reacting to user changing scale settings (100%, 125%, 150%, 175%)

Add-in Express™ Support Service
That's what is more important than anything else

Reacting to user changing scale settings (100%, 125%, 150%, 175%)
 
Andriy


Guest


Hello,

User has ability to change scale for resolution between 100%, 125%, 150%, 175% and we aren't able to react to that - content of our panel doesn't scale.

We are using WPF User control inside Element Host - what can we do to react to scale change and adjust our panel afterwards?

Thank you.
Posted 09 Oct, 2020 02:47:45 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hello Andriy,

Please check http://temp.add-in-express.com/support/WpfAndDpiChanged.zip.


Andrei Smolin
Add-in Express Team Leader
Posted 09 Oct, 2020 04:21:42 Top
Andriy


Guest


Hello,
Thank you for the sample you provided. It helped.
When I subscribe to the ADXDPIChanged event it works as expected.
But there are cases when I can't rely on this event only. For example, if I open a dialog window from my form, it can be located on another screen and I need to set scaling for this window separately (automatic scaling does not work in this case for WPF window).
Is there a way to get DPI factor of a screen where the window is currently located so that I can read and apply it for the window?

Thanks.
Posted 13 Oct, 2020 08:17:59 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hello Andriy,

The below refers to https://docs.microsoft.com/en-us/windows/win32/hidpi/high-dpi-improvements-for-desktop-applications.

You pass DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 or DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE to SetThreadDpiAwarenessContext() before you create a dialog. This lets your dialog window receive the WM_DPICHANGED messages. To find the initial DPI, see GetDpiForWindow().


Andrei Smolin
Add-in Express Team Leader
Posted 13 Oct, 2020 10:11:53 Top