0

I'm having 2 monitors. primary monitor -> One is with (100% DPI). Secondary monitor -> 4K monitor with (300% DPI). I used to drag the output window to secondary monitor. now the application output window is appearing in 4K monitor.

In my application, i have used to update images based on DPI. So i need to get DPI of current monitor where the application is showing. My code always gives DPI value of primary monitor.

Please share your ideas. Thanks.

Prithiv
  • 504
  • 5
  • 20
  • https://stackoverflow.com/questions/8151002/changing-secondary-monitor-screen-resolution-in-c-sharp – Rezaeimh7 Jan 20 '21 at 11:00
  • https://stackoverflow.com/questions/8151002/changing-secondary-monitor-screen-resolution-in-c-sharp – Rezaeimh7 Jan 20 '21 at 11:01
  • Google "windows forms wm_dpichanged" to find relevant hits. – Hans Passant Jan 20 '21 at 12:12
  • The Form class raises [DpiChanged](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.form.dpichanged) events and Controls [DpichangedAfterParent](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.control.dpichangedafterparent) and [DpichangedBeforeParent](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.control.dpichangedbeforeparent). Of course you need .Net Framework 4.7+ and your application must be DpiAware (otherwise, it's kind of useless). You can then check the `DeviceDpi` property. – Jimi Jan 20 '21 at 13:36
  • Also, see the notes here: [Using SetWindowPos with multiple monitors](https://stackoverflow.com/a/53026765/7444103) about the DpiAwareness, VirtualScreen, Screens and Monitors enumeration and the [GetScaleFactorForMonitor](https://learn.microsoft.com/en-us/windows/win32/api/shellscalingapi/nf-shellscalingapi-getscalefactorformonitor) function. This function (as you can see in the Remarks section), doesn't return a scale factor, but provides means to calculate it. – Jimi Jan 20 '21 at 13:43

0 Answers0