要設置dpi 意識,一般是使用SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE)來設置
具體可參考:Setting the default DPI awareness for a process
不過官方更建議使用清單文件來設置dpi意識,我介紹一下方法:
新建一個后綴為.manifest的文件,然后在其中添加如下代碼
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> <security> <requestedPrivileges> <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel> </requestedPrivileges> </security> </trustInfo> <application> <windowsSettings> <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware> <!-- legacy --> <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">permonitorv2,permonitor</dpiAwareness> <!-- falls back to pm if pmv2 is not available --> </windowsSettings> </application> </assembly>
保存后,在項目中添加這個文件,最后debug就可以了
請注意:也有其他方法可以設置dpi意識,看下圖
直接改選項就可以了