locked
Scaling MFC dialogs in an application to render correctly on high DPI devices RRS feed

  • Question

  • Hi,

    I need to make my MFC dialogs to render correctly on the new high-DPI devices. 

    I know how to get the scaling factors for X and Y directions. As of now, the only way I can see to scale all my dialogs is to scale each dialog and all UI controls on it, just before you show it to user. My DLL has a big number of dialogs and each dialog has many UI elements contained in it. If I go with dynamic re-scaling, it would be a huge work for me.

    Is there a way that could help me re-scaling all the dialogs by doing the scaling changes just at a single place? Or any other better alternative? It would be really helpful.

    Regards,

    Parul 



    Parul Gupta

    Thursday, March 27, 2014 4:21 PM

Answers

All replies

  • >I need to make my MFC dialogs to render correctly on the new high-DPI devices. 

    What's wrong that they don't work?

    See
    http://msdn.microsoft.com/en-us/library/windows/desktop/dn469266(v=vs.85).aspx
    "Scaling Layout"

    Dave

    Thursday, March 27, 2014 5:15 PM
  • Can you also please clarify on the below?

    1. Consider a system with 96 DPI as default DPI and an MFC application which has declared itself as DPI aware and has specified its dialogs coordinates as if it is being rendered on 96 DPI. Does the app developer need to take care of scaling the co-ordinates by checking the scaling level or does MFC itself takes care of scaling the co-ordinates? 

    (My question is for an application that will always run on a machine which has a default DPI value of 96,  but user has the flexibility to change Display scaling value up till 200%)?

    I am a bit confused on how Windows handles scaling on high resolution devices (where default DPI is much higher than 96) and Display scaling property change (which can be changed in the range of 10% to 200% on current systems with default DPI = 96)?


    Parul Gupta

    Saturday, March 29, 2014 8:55 AM
  • By the experiments I did,

    1. It Seems like that, increasing the scaling to 200% (say), OS itself scales all applications sizes to 2X (due to which not DPI aware applications may look blurry because of DPI virtualization and DPI aware apps (which has declared itself DPI aware in application manifest) do not look blurry because MFC is providing the scaled co-ordinates to render its UI even when the application has not written any code to scale its UI elements). Is this understanding correct?
    2. ANother question is why not the OS scales the same applications on a high-DPI device (where the default system DPI is 192 (say))?

    I am very unclear about the concept. Thanks for helping.



    Parul Gupta

    Saturday, March 29, 2014 9:09 AM
  • 1....Is this understanding correct?

    Essentially, but note that MFC has nothing to do with this (as far as
    I'm aware), it's just native Win32 behaviour.

    2. ANother question is why not the OS scales the same applications on a high-DPI device (where the default system DPI is 192 (say))?

    According to the MSDN article I referenced, 192 DPI should give 200%
    scaling (I've never tried it myself), so I don't know what's happening
    if its not for you.

    Dave

    Saturday, March 29, 2014 10:53 AM
  • In the second case, I am working on a high DPI device where default screen resolution is 3200x1600, screen size is 10x5, and default Display scaling is 125%. This is a Windows 8.1 machine (said to be a high DPI device).

    How does this make a difference?


    Parul Gupta

    Saturday, March 29, 2014 11:16 AM
  • Thank you so much for the response.

    That way you mean to say that there is no way provided by MFC that it can take care of scaling the dialogs itself, obviously the developer would need to take care of the icons at different DPIs.

    And if MFC does not provide any solution to this, that means I will need to scale each and every of my UI element programatically  by iterating over all the dialog elements, for each dialog.


    Parul Gupta

    Saturday, March 29, 2014 1:36 PM
  • In the second case, I am working on a high DPI device where default screen resolution is 3200x1600, screen size is 10x5, and default Display scaling is 125%. This is a Windows 8.1 machine (said to be a high DPI device).
    How does this make a difference?

    I don't know. I've not got any such device to play with to know what
    quirks there may be.

    Dave

    Saturday, March 29, 2014 2:01 PM
  • On a store site, I saw a notebook with an i7, gtx 780, and a ssd/hd combo with a 3k panel for $2499


    Corsair Carbide 300R with window
    Corsair TX850V2 70A@12V
    Asus M5A99FX PRO R2.0 CFX/SLI
    AMD Phenom II 965 C3 Black Edition @ 4.0 GHz
    G.SKILL RipjawsX DDR3-2133 8 GB
    EVGA GTX 6600 Ti FTW Signature 2(Gk104 Kepler)
    Asus PA238QR IPS LED HDMI DP 1080p
    ST2000DM001 & Windows 8.1 Enterprise x64
    Microsoft Wireless Desktop 2000
    Wacom Bamboo CHT470M
    Place your rig specifics into your signature like I have, makes it 100x easier to understand!

    Hardcore Games Legendary is the Only Way to Play!

    Saturday, March 29, 2014 2:03 PM
  • >On a store site, I saw a notebook with an i7, gtx 780, and a ssd/hd combo with a 3k panel for $2499

    And...? You're offerring to buy me one? :)

    Dave

    Saturday, March 29, 2014 5:32 PM
  • Hi Parul,

    According to your original issue that scaling MFC dialogs in an application to render correctly on high DPI devices, I think what David provided has already explained.

    In addition, is your MFC application setted as high DPI aware? Here is a tutorial that is intended for MFC developers who want to make their MFC desktop application high DPI aware.  A high DPI aware application can take full advantage of the DPI setting of the computer display without visual side-effects such as blurring, if the application is not high DPI aware. This may be helpful for you.

    May


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, April 3, 2014 8:27 AM