(No, I can't upgrade this codebase to .NET Core or newer yet.)
I have an app that's primarily Windows Forms, and partially WPF. When font size changes at runtime, WPF reacts correctly. Windows Forms, instead, doesn't even seem to realize anything has changed unless I restart. For example, the Control.DeviceDpi
property (which wasn't even introduced until 4.7) shows the value that was accurate at startup, not the current one.
My app.manifest
has:
<asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>True/PM</dpiAware>
</asmv3:windowsSettings>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
<dpiAwareness>PerMonitorV2, PerMonitor</dpiAwareness>
</asmv3:windowsSettings>
</asmv3:application>
My app.config
has:
<appSettings>
<add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />
</appSettings>
But 4.7 did introduce a Control.DpiChanged
event, only it never seems to fire.
Yet, if I override WndProc
and listen to WM_DPICHANGED
, that does fire. This code seems to suggest that the event should fire.
Apparently, it doesn't because this code conditionally turns it off. But I'm not sure which portion I don't qualify for. (I'm on Windows 10 21H1, so more recent than RS2.)