{"id":4013,"date":"2010-03-11T15:40:00","date_gmt":"2010-03-11T15:40:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2010\/03\/11\/mfc-applications-now-default-to-being-dpi-aware\/"},"modified":"2019-02-18T18:45:37","modified_gmt":"2019-02-18T18:45:37","slug":"mfc-applications-now-default-to-being-dpi-aware","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/mfc-applications-now-default-to-being-dpi-aware\/","title":{"rendered":"MFC applications now default to being DPI-aware"},"content":{"rendered":"<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">Hello, I\u2019m Pat Brenner, a developer on the Visual C++ Libraries team, mainly responsible for MFC.&nbsp; I wanted to make you aware of a subtle but meaningful change that we have made regarding MFC applications in Visual Studio 2010: all MFC applications are now marked as \u2018DPI aware\u2019 by default.&nbsp; This means that your application is expected to handle various DPI (dots-per-inch) settings, not just the default (96 DPI), because Windows will not automatically scale the user interface elements of your application to match the selected DPI of the system.<\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">The DPI of the system is set using the display settings in the Control Panel, as shown below.&nbsp; The \u2018Smaller\u2019 setting shown below corresponds to 96 DPI, while the \u2018Medium\u2019 and \u2018Larger\u2019 settings correspond to 120 and 144 DPI, respectively.<\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/MFC%20applications%20now%20default%20to%20being%20DPI-aware1.png\"><\/font><\/p>\n<p><font face=\"Calibri\"><\/p>\n<p class=\"MsoNormal\"><font size=\"3\">The terminology here is a bit confusing, because these settings don\u2019t really manipulate the dots-per-inch value.&nbsp; That value is actually controlled by the resolution used for the monitor\u2014a higher resolution results in more dots per inch on the screen.&nbsp; What these settings do is compensate for a higher resolution by making the text and other visual elements larger (using more pixels), so they do not appear too small on the screen.<\/font><\/p>\n<p class=\"MsoNormal\"><font size=\"3\">MFC has been updated to handle all of the adjustments necessary to support the DPI-aware scenarios in the user interface elements that it draws.&nbsp; Turning on DPI-awareness will trigger the use of appropriate scaling mechanisms in MFC so that fonts and images used in the user interface will be displayed with greater clarity.<\/font><\/p>\n<p class=\"MsoNormal\"><font size=\"3\">For example, below is a screen shot of a ribbon-based application, running on a system using the \u2018Larger\u2019 settings (144 DPI), without the DPI-awareness flag turned on.&nbsp; Windows is automatically scaling the UI elements to a larger size.&nbsp; Note that some elements appear slightly blurry.<\/font><\/p>\n<p class=\"MsoNormal\"><img decoding=\"async\" height=\"321\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/MFC%20applications%20now%20default%20to%20being%20DPI-aware2.png\" width=\"607\"><\/p>\n<p class=\"MsoNormal\"><font size=\"3\">And below is another screen shot of the same application, running on the same system, with the DPI-awareness flag turned on.&nbsp; Note the differences in the clarity of the text and images used.&nbsp; MFC is scaling the text and in some cases using different images.<\/font><\/p>\n<p class=\"MsoNormal\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/MFC%20applications%20now%20default%20to%20being%20DPI-aware3.png\"><\/p>\n<p class=\"MsoNormal\"><font size=\"3\">What this means to you, as a developer who uses MFC, is that you need to make sure that any custom drawing you do in your application is capable of handling the various DPI settings and adjusts as necessary, so that your application looks consistent across the various DPI settings.<\/font><\/p>\n<p class=\"MsoNormal\"><font size=\"3\">This change is accomplished via a setting in the global build properties file, Microsoft.CPP.Props, which sets the \u2018EnableDPIAwareness\u2019 flag to \u2018true\u2019 if the project is using MFC, either via the static MFC libraries or the shared MFC DLLs.&nbsp; When this flag is set to \u2018true\u2019, an additional manifest fragment is linked into your application which tells Windows that the application is DPI-aware.&nbsp; Note that this setting applies even to MFC applications that were created in a previous version of Visual Studio\u2014any application that uses MFC will be marked as DPI-aware.<\/font><\/p>\n<p class=\"MsoNormal\"><font size=\"3\">Of course, this is only the default, and it can be overridden if you wish.&nbsp; This means that Windows will automatically scale the UI elements of your application for you.&nbsp; This can be done by setting the \u2018Enable DPI Awareness\u2019 property to \u2018No\u2019 in the \u2018Input and Output\u2019 section of the \u2018Manifest Tool\u2019 properties for your application, as shown below:<\/font><\/p>\n<p class=\"MsoNormal\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/MFC%20applications%20now%20default%20to%20being%20DPI-aware4.png\"><\/p>\n<p class=\"MsoNormal\"><font size=\"3\">There is a more detailed topic about writing DPI-aware applications on MSDN <\/font><a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/dd464660(VS.85).aspx\"><font color=\"#0000ff\" size=\"3\">here<\/font><\/a><font size=\"3\">.&nbsp; Note that the information above updates some of the sections of that topic.<\/font><a class=\"\" name=\"_GoBack\"><\/a><font size=\"3\"> <\/font><\/p>\n<p class=\"MsoNormal\"><font size=\"3\">I hope you find this information helpful.&nbsp; Feel free to ask any questions you have and I\u2019ll do my best to answer them.<\/font><\/p>\n<p class=\"MsoNormal\"><font size=\"3\">Pat Brenner<\/font><\/p>\n<p class=\"MsoNormal\"><font size=\"3\">Visual C++ Libraries Development<\/font><\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p><\/font><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello, I\u2019m Pat Brenner, a developer on the Visual C++ Libraries team, mainly responsible for MFC.&nbsp; I wanted to make you aware of a subtle but meaningful change that we have made regarding MFC applications in Visual Studio 2010: all MFC applications are now marked as \u2018DPI aware\u2019 by default.&nbsp; This means that your application [&hellip;]<\/p>\n","protected":false},"author":289,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[42,43,44,10],"class_list":["post-4013","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cplusplus","tag-aware","tag-dpi","tag-high","tag-mfc"],"acf":[],"blog_post_summary":"<p>Hello, I\u2019m Pat Brenner, a developer on the Visual C++ Libraries team, mainly responsible for MFC.&nbsp; I wanted to make you aware of a subtle but meaningful change that we have made regarding MFC applications in Visual Studio 2010: all MFC applications are now marked as \u2018DPI aware\u2019 by default.&nbsp; This means that your application [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/4013","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/289"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=4013"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/4013\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/35994"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=4013"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=4013"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=4013"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}