[USER32] Improve DM_REPOSITION CORE-16490

This commit is contained in:
Katayma Hirofumi MZ 2019-11-16 12:52:40 +09:00
parent 657887adf4
commit f981a68ee0

View file

@ -1185,39 +1185,37 @@ static void DEFDLG_Reposition(HWND hwnd)
HMONITOR hMon; HMONITOR hMon;
MONITORINFO mi = { sizeof(mi) }; MONITORINFO mi = { sizeof(mi) };
RECT rc; RECT rc;
SIZE siz; LONG cx, cy;
if (GetWindowLongW(hwnd, GWL_STYLE) & WS_CHILD) if (GetWindowLongW(hwnd, GWL_STYLE) & WS_CHILD)
return; return;
hMon = MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY); hMon = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
if (!GetMonitorInfoW(hMon, &mi) || !GetWindowRect(hwnd, &rc)) if (!GetMonitorInfoW(hMon, &mi) || !GetWindowRect(hwnd, &rc))
return; return;
siz.cx = rc.right - rc.left; cx = rc.right - rc.left;
siz.cy = rc.bottom - rc.top; cy = rc.bottom - rc.top;
if (rc.right > mi.rcWork.right) if (rc.right > mi.rcWork.right)
{ {
rc.right = mi.rcWork.right; rc.right = mi.rcWork.right;
rc.left = rc.right - siz.cx; rc.left = rc.right - cx;
} }
if (rc.bottom > mi.rcWork.bottom - 4) if (rc.bottom > mi.rcWork.bottom - 4)
{ {
rc.bottom = mi.rcWork.bottom - 4; rc.bottom = mi.rcWork.bottom - 4;
rc.top = rc.bottom - siz.cy; rc.top = rc.bottom - cy;
} }
if (rc.left < mi.rcWork.left) if (rc.left < mi.rcWork.left)
{ {
rc.left = mi.rcWork.left; rc.left = mi.rcWork.left;
rc.right = rc.left + siz.cx;
} }
if (rc.top < mi.rcWork.top) if (rc.top < mi.rcWork.top)
{ {
rc.top = mi.rcWork.top; rc.top = mi.rcWork.top;
rc.bottom = rc.top + siz.cy;
} }
SetWindowPos(hwnd, NULL, rc.left, rc.top, 0, 0, SetWindowPos(hwnd, NULL, rc.left, rc.top, 0, 0,