I have a WIN32 SW which the UI was designed in 96 DPI, so when user changes the windows DPI from 96 to 120 or bigger, the UI will be wrong. I want to know if there is API to force my SW to display the UI with 96DPI.
Starting with Windows Vista, scaling for DPI is supposed to happen automatically. I don't have any direct experience to know how well it works, but here's the page that explains how to turn it off:
http://msdn.microsoft.com/en-us/library/ms701681(VS.85).aspx
There is no API to force your app to show at 96DPI. The DPI is a device setting and cannot be controlled per application.
If you can change your program, you can scale your UI to look properly on high DPI though. You need to call GetDeviceCaps; more specificaly, you need to calculate the X and Y scale using the number returned for LOGPIXELSX and LOGPIXELSY. Something like this:
HDC hdc;
double m_dDPIScaleX = GetDeviceCaps(hdc, LOGPIXELSX) / 96.0;
double m_dDPIScaleY = GetDeviceCaps(hdc, LOGPIXELSY) / 96.0;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With