Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DPI scaling
#1
Hi Gintaras,
Several of the computers at work are set to 125% = 120 DPI (Pixels/Dots Per Inch) instead of 100% (96 DPI). The Dialogs I created which have a toolbar-like row of buttons (with BMP or JPG's) across the top appear much wider at 100% (and therefore get cutoff as I am sizing them to a pre-existing application window). Everything gets fixed when I set the computer to 100% and re-login. However, this is an indiviudal user setting so every user would have to do this difficult step. I looked in help menu at DPI scaling functions and know I can detect the DPI setting with DpiGetDPI. This would allow me to have two versions of the toolbars hung and resized separately depending on the setting. However this is not so elegant and would rather have just one dialog setting that appears consistently at both settings. I read on StackFlow about AutoScale but I don't think this is a feature supported in QM.

http://stackoverflow.com/questions/93732...00-125-150

Quote:The correct way of handling variable DPI settings is not to detect them and adjust your controls' sizes manually in a switch statement (for starters, there are far more possibilities than those you show in your sample if statement). Instead, you should set the AutoScaleMode property of your form to AutoScaleMode.Dpi and let the framework take care of this for you.
Add the following code to your form's constructor (or set this property at design time):
this.AutoScaleMode = AutoScaleMode.Dpi;
Although you might prefer to use AutoScaleMode.Font. For more information on automatic scaling, see the MSDN documentation.

Is there any way to do this one set of code?

The window I am handing my Dlg on returns 0 on !DpiIsWindowScaled? when setting is at 100%

I geuss I should use DpiScale but not exactly sure how.

Does it make a difference whether I use bmp's or jpegs to skin my buttons?

S
#2
At >96 DPI, QM dialogs and their controls and text are scaled. Images are not scaled, regardless of type.
Non-dialog windows are not scaled. Text is scaled anyway.

If I correctly understand the problem, you need to use a non-dialog window. And set smaller font for controls if DPI on that computer is>96 and not using XP-style scaling.

QM does not have an AutoScaleMode.
#3
thanks.
I came across this and thought it might be of interest:
SetProcessDPIAware function
http://msdn.microsoft.com/en-us/library ... 43(v=vs.85).aspx

http://msdn.microsoft.com/en-us/library ... 81(v=vs.85).aspx

S


Forum Jump:


Users browsing this thread: 1 Guest(s)