Author Topic: New DPI handling  (Read 1711 times)

0 Members and 1 Guest are viewing this topic.

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 673
New DPI handling
« 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




Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 673
Re: New DPI handling
« Reply #1 on: November 28, 2016, 06:46:49 PM »

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

James

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 3131
  • Gender: Male
    • José Roca Software
Re: New DPI handling
« Reply #2 on: November 28, 2016, 07:44:37 PM »
Now you will understand why I have been so insistent about the DPI subject.

Offline Paul Squires

  • Full Member
  • ***
  • Posts: 152
  • Gender: Male
    • PlanetSquires
Re: New DPI handling
« Reply #3 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.
Paul Squires
FireFly Visual Designer SQLitening Database System JellyFish Pro Editor
http://www.planetsquires.com

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 673
Re: New DPI handling
« Reply #4 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

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 3131
  • Gender: Male
    • José Roca Software
Re: New DPI handling
« Reply #5 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.
« Last Edit: November 29, 2016, 03:45:38 PM by José Roca »

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 673
Re: New DPI handling
« Reply #6 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






Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 3131
  • Gender: Male
    • José Roca Software
Re: New DPI handling
« Reply #7 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.
« Last Edit: November 29, 2016, 04:22:56 PM by José Roca »

Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2405
  • Gender: Male
    • www.zapsolution.com
Re: New DPI handling
« Reply #8 on: November 29, 2016, 04:32:41 PM »
Changing the DPI setting, when using a multi-monitor configuration, is a NoNo!

...


« Last Edit: November 29, 2016, 04:34:34 PM by Patrice Terrier »
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com