https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8249d2a3fa3fc1b69400c2a6660dd46e62f8c2e8

commit 8249d2a3fa3fc1b69400c2a6660dd46e62f8c2e8
Author:     Katayama Hirofumi MZ <[email protected]>
AuthorDate: Sat Nov 16 09:51:16 2019 +0900
Commit:     GitHub <[email protected]>
CommitDate: Sat Nov 16 09:51:16 2019 +0900

    [USER32] Implement DM_REPOSITION message (#2020)
    
    DM_REPOSITION is dialog message that can reposition the dialog to the 
workarea when the dialog is partially/entirely in outside of the workarea. 
CORE-16490
---
 win32ss/user/user32/windows/dialog.c | 56 ++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/win32ss/user/user32/windows/dialog.c 
b/win32ss/user/user32/windows/dialog.c
index 8808ef89915..592e696e755 100644
--- a/win32ss/user/user32/windows/dialog.c
+++ b/win32ss/user/user32/windows/dialog.c
@@ -1179,7 +1179,52 @@ static BOOL DEFDLG_SetDefButton( HWND hwndDlg, 
DIALOGINFO *dlgInfo, HWND hwndNew
     return TRUE;
 }
 
+#ifdef __REACTOS__
+static void DEFDLG_Reposition(HWND hwnd)
+{
+    HMONITOR hMon;
+    MONITORINFO mi = { sizeof(mi) };
+    RECT rc;
+    SIZE siz;
+
+    if (GetWindowLongW(hwnd, GWL_STYLE) & WS_CHILD)
+        return;
+
+    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);
+}
+#endif
 /***********************************************************************
  *           DEFDLG_Proc
  *
@@ -1253,6 +1298,11 @@ static LRESULT DEFDLG_Proc( HWND hwnd, UINT msg, WPARAM 
wParam,
             }
             return 0;
 
+#ifdef __REACTOS__
+        case DM_REPOSITION:
+            DEFDLG_Reposition(hwnd);
+            return 0;
+#endif
         case WM_NEXTDLGCTL:
             if (dlgInfo)
             {
@@ -1692,6 +1742,9 @@ DefDlgProcA(
             case WM_SETFOCUS:
             case DM_SETDEFID:
             case DM_GETDEFID:
+#ifdef __REACTOS__
+            case DM_REPOSITION:
+#endif
             case WM_NEXTDLGCTL:
             case WM_GETFONT:
             case WM_CLOSE:
@@ -1752,6 +1805,9 @@ DefDlgProcW(
             case WM_SETFOCUS:
             case DM_SETDEFID:
             case DM_GETDEFID:
+#ifdef __REACTOS__
+            case DM_REPOSITION:
+#endif
             case WM_NEXTDLGCTL:
             case WM_GETFONT:
             case WM_CLOSE:

Reply via email to