我有一些代码将窗口定位到屏幕象限.它适用于Windows XP,7和8/8.1.但是,在Windows 10上,窗口之间存在奇怪的差距.四面环绕窗户的额外空间.我认为它与窗口边界有关,但无法弄清楚如何纠正问题.任何意见都将受到高度赞赏.代码如下:
// Get monitor info
HMONITOR hm = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
MONITORINFO mi;
mi.cbSize = sizeof(mi);
GetMonitorInfo(hm, &mi);
// Set screen coordinates and dimensions of monitor's work area
DWORD x = mi.rcWork.left;
DWORD y = mi.rcWork.top;
DWORD w = mi.rcWork.right - x;
DWORD h = mi.rcWork.bottom - y;
switch (corner) {
case 0: // Left top
SetWindowPos(hWnd, HWND_TOP, x, y, w / 2, h / 2, SWP_NOZORDER);
break;
case 1: // Right top
SetWindowPos(hWnd, HWND_TOP, x + w / 2, y, w / 2, h / 2, SWP_NOZORDER);
break;
case 2: // Right bottom
SetWindowPos(hWnd, HWND_TOP, x + w / 2, y + h / 2, w / 2, h / 2, SWP_NOZORDER);
break;
case 3: // Left bottom
SetWindowPos(hWnd, HWND_TOP, x, y + h / 2, w / 2, h / 2, SWP_NOZORDER);
break;
}
Run Code Online (Sandbox Code Playgroud)
小智 -3
Windows XP/7/8/8.1 的默认字体大小为 100%,但在 Windows 10 中默认以 125% 显示文本和项目。这直接影响所有窗口大小。
转到设置,显示,您会发现一个滚动条,将其移至 100%,所有内容的显示方式应与 Windows 8/7/XP 中相同
| 归档时间: |
|
| 查看次数: |
1181 次 |
| 最近记录: |