[PATCH] Ensure that GetSystemMenu returns valid HMENU unless bRevert explicitly requested

Brent Roman brent at mbari.org
Sun Jun 14 23:15:57 CDT 2009


---
 dlls/user32/menu.c |   50 +++++++++++++++++++++++---------------------------
 1 files changed, 23 insertions(+), 27 deletions(-)

diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c
index dd859b1..d7787fc 100644
--- a/dlls/user32/menu.c
+++ b/dlls/user32/menu.c
@@ -4009,35 +4009,31 @@ HMENU WINAPI GetSystemMenu( HWND hWnd, BOOL bRevert )
     HMENU retvalue = 0;
 
     if (wndPtr == WND_DESKTOP) return 0;
-    if (wndPtr == WND_OTHER_PROCESS)
-    {
-        if (IsWindow( hWnd )) FIXME( "not supported on other process window %p\n", hWnd );
-    }
-    else if (wndPtr)
-    {
-	if (wndPtr->hSysMenu && bRevert)
-	{
-            DestroyMenu(wndPtr->hSysMenu);
-            wndPtr->hSysMenu = 0;
-	}
-
-	if(!wndPtr->hSysMenu && (wndPtr->dwStyle & WS_SYSMENU) )
-	    wndPtr->hSysMenu = MENU_GetSysMenu( hWnd, 0 );
-
-	if( wndPtr->hSysMenu )
-        {
-	    POPUPMENU *menu;
-	    retvalue = GetSubMenu(wndPtr->hSysMenu, 0);
-
-	    /* Store the dummy sysmenu handle to facilitate the refresh */
-	    /* of the close button if the SC_CLOSE item change */
-	    menu = MENU_GetMenu(retvalue);
-	    if ( menu )
-	       menu->hSysMenuOwner = wndPtr->hSysMenu;
+    if (wndPtr == WND_OTHER_PROCESS) {
+      if (IsWindow( hWnd )) FIXME( "not supported on other process window %p\n", hWnd );
+    }else if (wndPtr) {
+      if (bRevert) {      	
+	    if (wndPtr->hSysMenu) {
+		DestroyMenu(wndPtr->hSysMenu);
+		wndPtr->hSysMenu = 0;
+	    }
+	  }else{
+	    if(!wndPtr->hSysMenu)
+	        wndPtr->hSysMenu = MENU_GetSysMenu( hWnd, 0 );
+	    if( wndPtr->hSysMenu ) {
+	      POPUPMENU *menu;
+	      retvalue = GetSubMenu(wndPtr->hSysMenu, 0);
+
+	      /* Store the dummy sysmenu handle to facilitate the refresh */
+	      /* of the close button if the SC_CLOSE item change */
+              menu = MENU_GetMenu(retvalue);    
+	      if (menu)
+	          menu->hSysMenuOwner = wndPtr->hSysMenu;
         }
-        WIN_ReleasePtr( wndPtr );
+      }
+      WIN_ReleasePtr( wndPtr );
     }
-    return bRevert ? 0 : retvalue;
+    return retvalue;
 }
 
 
-- 
1.6.1.76.gc123b


--------------060800050507050905070600--



More information about the wine-patches mailing list