當我使用 CreateWindowEx 創建一個視窗時,它會遵循解析度,但也會使用顯示設定中的比例設定。因此,在 1920 x 1080 中,如果我嘗試創建視窗,當比例為 150% 時,大小實際上是 1200 左右。有沒有辦法繞過這個限制?如果我只是手動將大小設定為 1920 x 1080,我會得到一個裁剪視窗。謝謝。
auto activeWindow = GetActiveWindow();
HMONITOR monitor = MonitorFromWindow(activeWindow, MONITOR_DEFAULTTONEAREST);
//
// Get the logical width and height of the monitor
MONITORINFOEX monitorInfoEx;
monitorInfoEx.cbSize = sizeof(monitorInfoEx);
GetMonitorInfo(monitor, &monitorInfoEx);
auto cxLogical = monitorInfoEx.rcMonitor.right - monitorInfoEx.rcMonitor.left;
auto cyLogical = monitorInfoEx.rcMonitor.bottom - monitorInfoEx.rcMonitor.top;
vScreenSize = { cxLogical, cyLogical };
WNDCLASS wc;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.hInstance = GetModuleHandle(nullptr);
wc.lpfnWndProc = olc_WindowEvent;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.lpszMenuName = nullptr;
wc.hbrBackground = nullptr;
wc.lpszClassName = olcT("Wusik SQ480 Engine");
RegisterClass(&wc);
DWORD dwExStyle = 0;
DWORD dwStyle = WS_VISIBLE | WS_POPUP;
olc::vi2d vTopLeft = vWindowPos;
// Keep client size as requested
RECT rWndRect = { 0, 0, vWindowSize.x, vWindowSize.y };
AdjustWindowRectEx(&rWndRect, dwStyle, FALSE, dwExStyle);
int width = rWndRect.right - rWndRect.left;
int height = rWndRect.bottom - rWndRect.top;
olc_hWnd = CreateWindowEx(dwExStyle, olcT("Wusik SQ480 Engine"), olcT(""), dwStyle,
vTopLeft.x, vTopLeft.y, width, height, NULL, NULL, GetModuleHandle(nullptr), this);
uj5u.com熱心網友回復:
感謝 Remy Lebeau,只需將以下呼叫添加到應用程式的主要初始化中即可。現在我總是得到一個具有物理解析度而不是邏輯縮放解析度的視窗。
SetProcessDPIAware();
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/442485.html
上一篇:如何從pid獲取命令列引數?
下一篇:C:Windows沒有找到HARDWARE\DEVICEMAP\SERIALCOMM,即使可以使用regedit找到它
