[2/2] user32: When inserting a menu item make sure that MDI system buttons stay on the right side

Dmitry Timoshkov dmitry at codeweavers.com
Sun Jun 17 07:46:26 CDT 2007


Hello,

this patch fixes a problem reported in the bug 8703.

Changelog:
    user32: When inserting a menu item make sure that MDI system buttons
    stay on the right side.

---
 dlls/user32/mdi.c  |   10 ++++++----
 dlls/user32/menu.c |    8 ++++++++
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/dlls/user32/mdi.c b/dlls/user32/mdi.c
index 5825220..0b488d2 100644
--- a/dlls/user32/mdi.c
+++ b/dlls/user32/mdi.c
@@ -307,7 +307,7 @@ static LRESULT MDISetMenu( HWND hwnd, HMENU hmenuFrame,
     MDICLIENTINFO *ci;
     HWND hwndFrame = GetParent(hwnd);
 
-    TRACE("%p %p %p\n", hwnd, hmenuFrame, hmenuWindow);
+    TRACE("%p, frame menu %p, window menu %p\n", hwnd, hmenuFrame, hmenuWindow);
 
     if (hmenuFrame && !IsMenu(hmenuFrame))
     {
@@ -323,6 +323,8 @@ static LRESULT MDISetMenu( HWND hwnd, HMENU hmenuFrame,
 
     if (!(ci = get_client_info( hwnd ))) return 0;
 
+    TRACE("old frame menu %p, old window menu %p\n", ci->hFrameMenu, ci->hWindowMenu);
+
     if (hmenuFrame)
     {
         if (hmenuFrame == ci->hFrameMenu) return (LRESULT)hmenuFrame;
@@ -844,12 +846,12 @@ static BOOL MDI_AugmentFrameMenu( HWND frame, HWND hChild )
     }
 
     AppendMenuW(menu, MF_HELP | MF_BITMAP,
-                SC_MINIMIZE, (LPCWSTR)HBMMENU_MBAR_MINIMIZE ) ;
+                SC_CLOSE, is_close_enabled(hChild, hSysPopup) ?
+                (LPCWSTR)HBMMENU_MBAR_CLOSE : (LPCWSTR)HBMMENU_MBAR_CLOSE_D );
     AppendMenuW(menu, MF_HELP | MF_BITMAP,
                 SC_RESTORE, (LPCWSTR)HBMMENU_MBAR_RESTORE );
     AppendMenuW(menu, MF_HELP | MF_BITMAP,
-                SC_CLOSE, is_close_enabled(hChild, hSysPopup) ?
-                (LPCWSTR)HBMMENU_MBAR_CLOSE : (LPCWSTR)HBMMENU_MBAR_CLOSE_D );
+                SC_MINIMIZE, (LPCWSTR)HBMMENU_MBAR_MINIMIZE ) ;
 
     /* The system menu is replaced by the child icon */
     hIcon = (HICON)SendMessageW(hChild, WM_GETICON, ICON_SMALL, 0);
diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c
index 6706e16..0e0f93f 100644
--- a/dlls/user32/menu.c
+++ b/dlls/user32/menu.c
@@ -2101,6 +2101,14 @@ static MENUITEM *MENU_InsertItem( HMENU hMenu, UINT pos, UINT flags )
         }
     }
 
+    /* Make sure that MDI system buttons stay on the right side */
+    while (pos > 0 && (menu->items[pos - 1].wID == SC_MINIMIZE ||
+                       menu->items[pos - 1].wID == SC_RESTORE ||
+                       menu->items[pos - 1].wID == SC_CLOSE))
+        pos--;
+
+    TRACE("inserting at %u by pos %u\n", pos, flags & MF_BYPOSITION);
+
     /* Create new items array */
 
     newItems = HeapAlloc( GetProcessHeap(), 0, sizeof(MENUITEM) * (menu->nItems+1) );
-- 
1.5.1.6






More information about the wine-patches mailing list