Powerbasic Museum 2020-B

IT-Consultant: James C. Fuller => bc9Basic => Topic started by: James C. Fuller on November 28, 2016, 02:22:08 PM

Title: New DPI handling
Post by: James C. Fuller on November 28, 2016, 02:22:08 PM

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



Title: Re: New DPI handling
Post by: James C. Fuller on November 28, 2016, 06:46:49 PM

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

James
Title: Re: New DPI handling
Post by: José Roca on November 28, 2016, 07:44:37 PM
Now you will understand why I have been so insistent about the DPI subject.
Title: Re: New DPI handling
Post by: Paul Squires on November 28, 2016, 10:13:14 PM
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.
Title: Re: New DPI handling
Post by: James C. Fuller on November 29, 2016, 02:37:21 PM
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
Title: Re: New DPI handling
Post by: José Roca on November 29, 2016, 02:51:03 PM
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.
Title: Re: New DPI handling
Post by: James C. Fuller on November 29, 2016, 03:45:18 PM
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





Title: Re: New DPI handling
Post by: José Roca on November 29, 2016, 04:16:07 PM
> 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.
Title: Re: New DPI handling
Post by: Patrice Terrier on November 29, 2016, 04:32:41 PM
Changing the DPI setting, when using a multi-monitor configuration, is a NoNo!

...