我有一个带有父窗口和 4 个子窗口的简单应用程序。它看起来很好Windows xp
并显示设置Windows 7
。125%
然而,在Windows 7
不止125%
其Windows 10
125%
本身上,窗口、菜单、文本和消息框变得模糊,并且子窗口被溢出。
我想修复它们,使它们看起来很好,所以我尝试根据 dpi 用更新的尺寸替换它们的尺寸:
//Get resoulation
int resX=GetSystemMetrics(SM_CXVIRTUALSCREEN) , resY=GetSystemMetrics(SM_CYVIRTUALSCREEN);
//Get current dpi
HDC screen = GetDC(0);
int dpiX = GetDeviceCaps(screen, LOGPIXELSX);
int dpiY = GetDeviceCaps(screen, LOGPIXELSY);
//Do some calculations about the resoulation
if( resX <= 800 ){
winWidth=resX/1.45;
winHeight=resY/1.3;
}
//...
//Update width and height of the main window according to the current dpi
int updatedWinWidth=(winWidth * dpiX) / 96 , updatedWinHeight=(winHeight * dpiY) / 96 ;
//Creating parent window with updated width and height
hwnd=CreateWindowEx( WS_EX_CLIENTEDGE , myClassName , L"Compressor Reporter" , WS_OVERLAPPED | WS_MINIMIZEBOX | WS_SYSMENU ,CW_USEDEFAULT, CW_USEDEFAULT, updatedWinWidth , updatedWinHeight, NULL , NULL , hInstance , NULL );
//Updating width and height for child window, width and height variables are the dafault width and height for the child
int updatedWidth = ( width * dpiX) / 96 , updatedHeight= (height * dpiY) / 96;
//Creating the child window
hwndList1 = CreateWindow(WC_LISTVIEW , L"" , WS_VISIBLE | WS_CHILD | LVS_REPORT | WS_BORDER | WS_VSCROLL | LVS_OWNERDRAWFIXED, middle-(10+updatedWidth) , middleH-(10+updatedHeight) , updatedWidth , updatedHeight, hwnd, NULL, GetModuleHandle(NULL), 0);
//Font settings
HDC hdc=GetDC( hHeader1);
int points=0;
switch(GetDeviceCaps( hdc , LOGPIXELSY)){
case 96:
points=11;
break;
default:
points=10.5;
}
int fonth=-MulDiv(points, GetDeviceCaps( hdc , LOGPIXELSY) , 72 );
ReleaseDC(hHeader1 , hdc);
hF2=CreateFont(fonth, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, L"Tahoma");
SendMessage(hHeader1,WM_SETFONT,(WPARAM)hF2,MAKELPARAM(TRUE,0));
但是,结果是一样的。
我还更改Compressor Reporter.exe.embed.manifest
并在其中添加application
标签,如下所示。但是当我重建我的应用程序时,我添加的内容没有出现,我看到没有application
标签。
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
<dpiAware>true</dpiAware>
</windowsSettings>
</application>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
我做错了什么,如何修复模糊的窗口、文本、菜单和消息框并使子窗口正确定位?
谢谢