locked
Programmatically override high DPI setting RRS feed

  • Question

  • The (Creator's Update) option for End User " Override High DPI Scaling Behavior " = System (Enhanced) works really well for my win32 desktop application. But I want to know how to switch this ON programmatically or through a Manifest. Any ideas?

    Thanks.

    Saturday, March 17, 2018 5:51 AM

Answers

  • Well, once you know what to look for it is easy to find what you want.

    This blog post explains the administrative ways of enabling GDI scaling. Since you can edit the manifest, the very last one is the one that you want.


    This is a signature. Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    • Marked as answer by SanjaySk Saturday, March 17, 2018 8:54 AM
    Saturday, March 17, 2018 7:51 AM

All replies

  • Hi SanjaySk,

    thanks for posting here.

    >>The (Creator's Update) option for End User " Override High DPI Scaling Behavior " = System (Enhanced) works really well for my win32 desktop application. But I want to know how to switch this ON programmatically or through a Manifest. Any ideas?

    For this case, I suggest you use SetProcessDpiAwareness method with PROCESS_DPI_AWARENESS enumeration. You could enable the Syetem with PROCESS_SYSTEM_DPI_AWARE.

    Here is a document about High-DPI scaling for desktop applications, you could get more information from it.

    https://blogs.windows.com/buildingapps/2017/04/04/high-dpi-scaling-improvements-desktop-applications-windows-10-creators-update/#gU6qkKJL3qSUsXRS.97

    Hope this could be help of you.

    Best Regards,

    Baron Bi


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Saturday, March 17, 2018 6:38 AM
  • You may also want to check out this blog post.
    Saturday, March 17, 2018 6:57 AM
  • The information you point is pre-Creator's Update. It's just related to switching DPIAwareness ON or OFF. You don't get any choice to specify the latest setting System (Enhanced). The End User gets several choices in that Properties dialog--Application, System and System (Enhanced). Please check the article I point to that describes what happens on System (Enhanced) choice. I would like to get an answer from that development team that wrote that blog article. Only they would know.

    Thanks.

    Saturday, March 17, 2018 7:08 AM
  • For Creators onwards, you can set this at a per thread level using SetThreadDpiAwarenessContext as is stated in the blog link that was provided.

    Because it is a thread level thing you need to call this on each thread that you want to change from the default, where the default is set in the manifest. So if you don't want to set the manifest, you would then need to call SetThreadDpiAwarenessContext on every thread that you create a window on.

    *Edit*

    If you want to enable System (Enhanced) without changing the shortcuts or executable properties, this is probably a compatibility shim that you can enable in the usual way.


    This is a signature. Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    • Edited by Darran Rowe Saturday, March 17, 2018 7:27 AM
    Saturday, March 17, 2018 7:19 AM
  • Please try to understand the question.

    I'm not asking about switching DPIAwareNess ON or OFF. I'm asking about the specific "System (Enhanced)" setting to set for the Non DPIAwareness, a feature that the End User seems to get but not available through any API or Manifest. If you still don't understand what I'm asking, please read that article and in particular the section that describes "System (Enhanced)"setting available to the end user.

    Saturday, March 17, 2018 7:28 AM
  • Hence the edit.

    I'm waiting for the right things to install to double check, but you must remember that the specific System (Enhanced) setting you are talking about is a setting for applications where changing the application to be fully DPI aware is not an option. It still doesn't beat changing the application code to be fully PMv2 capable, which requires code changes.

    This is why this is a compatibility setting and not a programmatic setting. It is only intended for those applications where you are unable to change things at all. If you are at the level of being able to ask this question then the intention is that you modify your application.

    So if you want to enable this, you should be asking how to enable the application compatibility setting for your application, not asking how to programmatically enable this.

    Once the correct things are installed, I'll provide an update.


    This is a signature. Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    Saturday, March 17, 2018 7:42 AM
  • Well, once you know what to look for it is easy to find what you want.

    This blog post explains the administrative ways of enabling GDI scaling. Since you can edit the manifest, the very last one is the one that you want.


    This is a signature. Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    • Marked as answer by SanjaySk Saturday, March 17, 2018 8:54 AM
    Saturday, March 17, 2018 7:51 AM
  • It is stored in the registry.

    HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers

    then exe name for the value

    and flags like :

    ~ GDIDPISCALING DPIUNAWARE

    Saturday, March 17, 2018 8:12 AM
  • OK. That certainly helps. I get it now. System (Enhanced) is a combination of Manifest settings for DPIAware and GDI Scaling. I will experiment and find out what settings I need.

    Many thanks.

    Saturday, March 17, 2018 8:54 AM
  • That seems to be another way of doing this, by changing the registry setting through the installer.

    Thanks.


    • Edited by SanjaySk Saturday, March 17, 2018 8:56 AM
    Saturday, March 17, 2018 8:55 AM