Announcement

Collapse
No announcement yet.

High-DPI using Cwindow & headers

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • High-DPI using Cwindow & headers

    I've been experimenting with the CWindow class and converted one of my simpler DDT apps over. Looks and works the same, but compile time is stunningly faster!

    Anyway, I now want to add High-DPI support. I've set the Manifest to use the "dpiAware" setting of True but done nothing else. The app shows sharp and clear on my laptop display (1920x1280, scaling at 120%) but is less sharp on my other two monitors (1680x1050, 100%, 1280x1024, 100%). I've searched the forums and found a little about DPI-aware and read the MS topics. My question is that the CWindow and the AfxWin classes have a number of interesting DPI functions, like AfxFontModifyPointSize, rxRatio, etc.

    So what is the proper approach for DPI-aware using these classes?

    Thanks!
    Mark Newman

  • #2
    If you're using a DPI of 120% or less, you should not notice any difference, since Windows uses virtualization with DPIs higher than 120%.

    The concept is simple. If a user chooses a high DPIs setting it is because it wants to see the GUI elements bigger, for more confortable reading, and the proper way to do it is scaling. If the application is not DPI aware, Windows vrtualizes it. What it does is to create a bitmap and display it stretched. If the scaling is high, then it loses sharpness.

    What CWindow does is to do the scaling for you. That is, if you're using a DPI of 192% (2x scaling), if you create a button 75 pixels wide it will scale it to 150 pixels. When the same application is run in another computher with different DPI, it will scale it accordingly the appropiate ratio. But CWindow is not necessary to do it: you can use pure SDK or DDT and do the scaling by yourself, that is, you calculate the scaling ratio and you multiply sizes and coordinates by that ratio. If the application is DPI aware, using DDT with dialog units instead of pixels will also take care of the scaling, although the scaling mode is different for dialogs. I'm not using CWindow just for scaling, but as an easier way to work with SDK windows instead of using the verbose method of filling a WNDCLASSEX structure, registering the class, etc. Automatic scaling is an added feature.

    DPI related functions in AfxWin.inc, such AfxScaleX and AfxScaleY are provided to help you to do scaling if you aren't using CWindow to build your GUI.

    Forum: http://www.jose.it-berater.org/smfforum/index.php

    Comment


    • #3
      > The app shows sharp and clear on my laptop display (1920x1280, scaling at 120%) but is less sharp on my other two monitors (1680x1050, 100%, 1280x1024, 100%).

      It must be because other things, like drivers, the font used... At 100% DPI, CWindow won't do any scaling, and even when it does scaling, it does not affect to the resolution, only to the size.
      Forum: http://www.jose.it-berater.org/smfforum/index.php

      Comment


      • #4
        Interesting, I didn't know that DDT did the scaling too; the DDT version of my app also shows the same display fuzziness.

        One of the external monitors is supported directly by the laptop, but the other runs from a Plugable USB adapter so perhaps that's part of the problem. I'll look at the fonts and drivers next.

        Thank you for the help!
        Mark Newman

        Comment


        • #5
          Originally posted by Mark Newman View Post
          Interesting, I didn't know that DDT did the scaling too; the DDT version of my app also shows the same display fuzziness.
          Try adding this to a manifest for ddt dialogs to see if the text clears up a bit.
          Code:
                <asmv3:application>
                   <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
                      <dpiAware>true</dpiAware>
                   </asmv3:windowsSettings>
                </asmv3:application>
          James




          Comment


          • #6
            Yep, I have that flag set in the manifest for both the CWindow and DDT versions of the app, and the display characteristics are the same for both apps. As Jose pointed out, I likely have something else affecting the appearance so I'll check further into that.

            Thanks just the same! I'm having fun with the CWindow class and will likely convert more of my apps over to that.
            Mark Newman

            Comment

            Working...
            X