0

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.

Yngve Hammersland
  • 1,634
  • 2
  • 14
  • 28
  • 4
    The real DPI depends on the output device (screen, printer, etc), so it should be set at the output driver level. It doesn't make *sense* to set it on a per-Application basis. – Quentin Nov 06 '09 at 13:47
  • @David Actually it does make sense. It's running on a device with touch screen and to make it more touch friendly I want to make everything bigger (with as little effort as possible). I do however want to keep the system DPI intact for windows and the other applications. – Yngve Hammersland Nov 06 '09 at 13:53
  • No it doesn't make sense, DPI is not a per-application setting or even an application-level concept. You will need to increase the size of all controls manually. – Roel Nov 06 '09 at 14:54
  • @David Ok, I agree, it doesn't really make sense since DPI is meant to reflect your screen resolution. My goal is to enable Vista's automatic application scaling without changing the scale of the whole system. – Yngve Hammersland Nov 06 '09 at 15:12
  • That should be @Roel. Sorry for any confusion.. :-s – Yngve Hammersland Nov 06 '09 at 15:13

1 Answers1

1

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.

Community
  • 1
  • 1
tijmenvdk
  • 1,773
  • 10
  • 19
  • I'm trying to achieve the same effect the system-wide setting has but on my application only. In other words, I want to let windows auto-scale my application but I want the application to supply the DPI. – Yngve Hammersland Nov 06 '09 at 14:13