From: "katahiromz ." Subject: [PATCH] user32: Implement DM_REPOSITION message Message-Id: Date: Thu, 7 Nov 2019 14:58:09 +0900 See attachment. From e29a3021cbdb91917f93c9b9468d9063891188f8 Mon Sep 17 00:00:00 2001 From: Hirofumi Katayama Date: Thu, 7 Nov 2019 14:41:39 +0900 Subject: [PATCH] user32: Implement DM_REPOSITION message Dialog Message DM_REPOSITION was not implemented. This message realizes repositioning of dialog boxes. Signed-off-by: Hirofumi Katayama --- dlls/user32/defdlg.c | 47 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/dlls/user32/defdlg.c b/dlls/user32/defdlg.c index 00a73c6b92..52d259fc5b 100644 --- a/dlls/user32/defdlg.c +++ b/dlls/user32/defdlg.c @@ -208,6 +208,47 @@ static BOOL DEFDLG_SetDefButton( HWND hwndDlg, DIALOGINFO *dlgInfo, HWND hwndNew return TRUE; } +static void DEFDLG_Reposition(HWND hwnd) +{ + HMONITOR hMon; + MONITORINFO mi = { sizeof(mi) }; + RECT rc; + SIZE siz; + + hMon = MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY); + + if (!GetMonitorInfoW(hMon, &mi) || !GetWindowRect(hwnd, &rc)) + return; + + siz.cx = rc.right - rc.left; + siz.cy = rc.bottom - rc.top; + + if (rc.right > mi.rcWork.right) + { + rc.right = mi.rcWork.right; + rc.left = rc.right - siz.cx; + } + if (rc.bottom > mi.rcWork.bottom) + { + rc.bottom = mi.rcWork.bottom; + rc.top = rc.bottom - siz.cy; + } + + if (rc.left < mi.rcWork.left) + { + rc.left = mi.rcWork.left; + rc.right = rc.left + siz.cx; + } + if (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, + SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE | + SWP_NOZORDER); +} /*********************************************************************** * DEFDLG_Proc @@ -279,6 +320,10 @@ static LRESULT DEFDLG_Proc( HWND hwnd, UINT msg, WPARAM wParam, } return 0; + case DM_REPOSITION: + DEFDLG_Reposition(hwnd); + return 0; + case WM_NEXTDLGCTL: if (dlgInfo) { @@ -383,6 +428,7 @@ LRESULT WINAPI DefDlgProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) case WM_SETFOCUS: case DM_SETDEFID: case DM_GETDEFID: + case DM_REPOSITION: case WM_NEXTDLGCTL: case WM_GETFONT: case WM_CLOSE: @@ -441,6 +487,7 @@ LRESULT WINAPI DefDlgProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) case WM_SETFOCUS: case DM_SETDEFID: case DM_GETDEFID: + case DM_REPOSITION: case WM_NEXTDLGCTL: case WM_GETFONT: case WM_CLOSE: -- 2.23.0