I have a code that positions windows to display quadrants. It works fine on Windows XP, 7 and 8 / 8.1. However, in Windows 10 there is a strange gap between the windows. Additional space surrounds the window on all sides. I suppose this has something to do with the borders of the window, but cannot figure out how to fix the problem. Any input would be greatly appreciated. The code is as follows:
// 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 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; }
windows winapi
Paul
source share