New DPI handling

Started by James C. Fuller, November 28, 2016, 02:22:08 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

James C. Fuller


The built-in GUI (BCX_XXXX) functions of both bc9 and BCX hold up pretty well on on displays not using the default 96 DPI. The sizing is not bad but the text is fuzzy.
I have added DPI to the GUI statement to provide true DPI handling.
Just use:
  GUI "MyClassName",DPI
where you would normally use
  GUI "MyClassName",PIXELS

The new update to the bc9Basic translator should be available later today.

The images are from my Win10 laptop at 150% (144 DPI)


James




James C. Fuller


And this is what it looks like with no dpi awareness at all.

James

José Roca

Now you will understand why I have been so insistent about the DPI subject.

Paul Squires

It took a lot of us a long time to finally realize the importance of high DPI awareness. Likewise, it's taken us a while to understand the importance of unicode awareness as well.
Paul Squires
FireFly Visual Designer SQLitening Database System JellyFish Pro Editor
http://www.planetsquires.com

James C. Fuller

José,
  Even if your code is dpi aware it still may not display correctly on a monitor that just doesn't have enough size to display your window.
How would you check at the beginning of your app if your complete window will display?? Cwindow, AfxWin, or generic.
  Thank you,
James

José Roca

#5
Once you have created the window, but before displaying it, get its dimensions. Get also the dimensions of the working area with SystemParametersInfo. If the window is bigger that the working area, shrink the size of the main window and make it scrollable using the CScrollWindow class.

Of course, if you have scrollable controls that also exceed the limits, such a ListBox, you may need to do further adjustments.

Another possibility is to calculate the DPI at which the window will fit, and set it with the pWindow.DPI property before creating the window and controls. This is equivalent to doing a limited scaling.

James C. Fuller

José,
  Thank you.

I just did a few more tests and found this:

Window is created with normal CreateWindowEx functions with no dpiAware section in the manifest the window displays the correct adjusted size on my 150% display but the fonts are fuzzy.

Window is created with dpi aware functions and a dpiAware section in the manifest. All is fine with an adjusted windows size and clear Fonts.

Window is created with normal CreateWindowEx functions but I lie and have a dpiAware section in the manifest. The window displays like the last one on my 150% display. I don't see this ever happening except by mistake?



José, Does CWindow handle a setup with two monitors extending the view with different dpi settings?


James






José Roca

#7
> José, Does CWindow handle a setup with two monitors extending the view with different dpi settings?

This is a potential problem that I can't test, because I have Windows 7 and only one monitor. Windows 8.1 and above provides new apis to set the application to per monitor-DPI aware.

See: https://msdn.microsoft.com/en-us/library/windows/desktop/dd464659(v=vs.85).aspx
for a tutorial.

Having to resize everything, create new fonts, load new icons, etc., is going to we very messy.

Patrice Terrier

#8
Changing the DPI setting, when using a multi-monitor configuration, is a NoNo!

...


Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com