工做緣由,須要維護一款VS2008 SP1開發的MFC項目,
發現WIN10高分辨率下顯示模糊,不考慮升級VC版本狀況下嘗試解決shell
新版本VC中Manifest Tool
>Input and Output
內有一項dpiAware
,應該是加了對應清單項,
嘗試添加一下內容到hdpi.xml
並Manifest Tool
>Input and Output
>Additional Manifest Files
添加hdpi.xml
windows
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> <asmv3:application> <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"> <dpiAware>true</dpiAware> </asmv3:windowsSettings> </asmv3:application> </assembly>
報錯manifest authoring warning 81010002: Unrecognized Element "application" in namespace "urn:schemas-microsoft-com:asm.v3".
參考https://social.msdn.microsoft.com/Forums/vstudio/en-US/ab815aa4-bd4d-4ab2-8826-fa20b0816372/how-to-make-application-to-fit-dpi-setting
應該是mt.ex版本問題api
利用win8.1後新API,完美解決
SetProcessDpiAwarenessapp
示例代碼,兼容MinGW、VC,不區分C/C++spa
#define UNICODE #include <windows.h> static void _DpiNohelp() { typedef HRESULT (WINAPI *FSetProcessDpiAwareness)(int value); HMODULE m = NULL; FARPROC proc = NULL; if(m = LoadLibrary(L"shcore.dll")) { if(proc = GetProcAddress(m, "SetProcessDpiAwareness")) ((FSetProcessDpiAwareness)proc)(2); FreeLibrary(m); } } int main() { _DpiNohelp(); MessageBox(0,0,0,0); }