Since you want your executable to run on both Windows 7 and Windows 10, you cannot link against GetDpiForWindow and GetDpiForMonitor because those functions do not exist in Windows 7. To do this, you can call GetDpiForWindow, or MonitorFromWindow + GetDpiForMonitor. But if you declare PerMonitorV2, then you are obliged to implement per-monitor DPI correctly. On Windows 10, if you declare DPI awareness per monitor, GetDeviceCaps will not suffice because it only returns the DPI setting for the main display. This will also do fine on Windows 10 if and only if you do not declare DPI awareness per monitor. GetDeviceCaps has been the way to get this setting since Windows XP. (1) This will give you the DPI setting of the main monitor. Then, on Windows 7, you get the scaling factor using the GetDeviceCaps function with LOGPIXELSX and LOGPIXELSY, and dividing the result by 96 (because 96 dpi is "100%"). This is a compatibility measure that ensures that applications which do not implement DPI code can still appear bigger. If you do not include this manifest, Windows will virtualize the DPI, meaning it will act as if the DPI setting is always at 96 (100%), and then Windows merely scales the bitmaps (blurry). It declares per-monitor DPI awareness ( DPI_AWARENESS_PER_MONITOR_AWARE), which means that each monitor can have different DPI settings and your application must handle that correctly. System-wide means that it assumes that all applications on all monitors use the same DPI setting).ĭpiAwareness is recognized by Windows 10 (Windows 7 ignores it) and, if present, supersedes dpiAware. You need to merge this into your manifest: ĭpiAware true is recognized by Windows 7 and Windows 10, and declares system-wide DPI awareness ( DPI_AWARENESS_SYSTEM_AWARE). How can I get this "make everything bigger" and the "make text bigger" settings on a Windows 7 or 10 system?īuild system: 64-bit Windows 7, Visual Studio 2019 16.7.7 Run system: Windows 7 or laterĪfter discussing in the comments, it turns out your actual problem is that you don't declare DPI awareness in your manifest correctly. To the manifest, when I run the app on Windows 10, I get a "side-by-side" error. Probably because the app is being built on a Windows 7 system, the VS-generated manifest does not include Windows 10 as a supported O/S. Per the MS docs, Visual Studio is adding "dpiAware" to the manifest (this is a setting I can change). I have tried several proposed solutions based on getting the ratio of device caps parameters, but they all get 1.0 on a Windows 10 system where the Windows "Make everything bigger" setting is 150%. My C++ app must run on Windows 7 or higher. In this question, it's explained how to get the font scaling percentage, but the suggested function GetScaleFactorForMonitor requires Windows 8.1. My goal is to be able to adjust the font size at runtime in a C++ app, based on the monitor resolution.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |