mfcwinapidpi

Is it possible to set the DPI of an application programatically?


Is it possible to set the DPI of an application programmatically or the DPI only possible to set through the system preference?

Note: My application's GUI is coded in MFC and .NET forms.

Update: After some research I have found no way of doing this so I have to agree with the only answer here; it cannot be done.


Solution

  • Assuming that you are talking about the Windows system-wide setting that determines the ratio between the physical DPI setting (that depends on the physical screen + resolution), the simple answer is "you can't", at least, not on at the application level in a WinForms app.

    What you can do, is add scaling code to your form, see this StackOverflow entry. Basically, set the AutoScaleMode to ScaleMode.Dpi. See the other entry for more info.