WinForms (.NET Framework) doesn't seem to notice DPI sessions between RDP sessions

Viewed 37

It seems that, in the following scenario, Windows Forms won't notice a DPI change without a restart of the app:

  1. connect to an RDP session
  2. launch the app
  3. disconnect; reconnect, but with a different DPI setting in the RDP client

This seems to be because in such a scenario, Windows never sends WM_DPICHANGED (as of Windows 11 22000.194, anyway), and that seems to be the only way Windows Forms notices changes.

Windows does send WM_DISPLAYCHANGE, though, which includes the new DPI.

From decompiling WinForms, it seems I could listen to that message and construct my own DpiChangedEventArgs to have controls notice the change.

Before I endeavour on that,

  • can someone confirm this behavior? There are probably other scenarios it applies to? (i.e., a display gets disconnected, then on reconnect has a different DPI, and WinForms doesn't notice as a result)
  • is there a nicer fix I'm missing, other than to send the event myself?
0 Answers
Related