user: Fix SetMenu after CreateWindow for invisible window

Michal Janusz Miroslaw M.Miroslaw at elka.pw.edu.pl
Fri Sep 19 08:56:37 CDT 2003


I'm back, after a while. :)

Example app fixed: DesignWorks 3.20 (still not working, BTW)
(This app creates window of size about (200,1) and later adds dynamically
created menu to it before showing it.)

ChangeLog:
  - Fix adding of menu after CreateWindow*() and before ShowWindow()

Index: dlls/user/controls.h
===================================================================
RCS file: /home/wine/wine/dlls/user/controls.h,v
retrieving revision 1.12
diff -u -r1.12 controls.h
--- dlls/user/controls.h	10 Sep 2003 03:56:47 -0000	1.12
+++ dlls/user/controls.h	19 Sep 2003 03:14:34 -0000
@@ -62,6 +62,7 @@
 extern UINT MENU_DrawMenuBar( HDC hDC, LPRECT lprect,
                                 HWND hwnd, BOOL suppress_draw );
 extern UINT MENU_FindSubMenu( HMENU *hmenu, HMENU hSubTarget );
+extern BOOL MENU_SetMenu(HWND hWnd32, HMENU hMenu);
 
 /* scrollbar */
 extern void SCROLL_DrawScrollBar( HWND hwnd, HDC hdc, INT nBar, BOOL arrows, BOOL interior );
Index: windows/win.c
===================================================================
RCS file: /home/wine/wine/windows/win.c,v
retrieving revision 1.224
diff -u -r1.224 win.c
--- windows/win.c	5 Sep 2003 23:15:39 -0000	1.224
+++ windows/win.c	19 Sep 2003 03:14:43 -0000
@@ -1115,7 +1115,7 @@
     if (((wndPtr->dwStyle & (WS_CAPTION|WS_CHILD)) == WS_CAPTION) ||
         (wndPtr->dwExStyle & WS_EX_APPWINDOW))
     {
-        if (cs->hMenu) SetMenu(hwnd, cs->hMenu);
+        if (cs->hMenu) MENU_SetMenu(hwnd, cs->hMenu);
         else
         {
             LPCSTR menuName = (LPCSTR)GetClassLongA( hwnd, GCL_MENUNAME );
@@ -1126,7 +1126,7 @@
                 else
                     cs->hMenu = HMENU_32(LoadMenu16(HINSTANCE_16(cs->hInstance),menuName));
 
-                if (cs->hMenu) SetMenu( hwnd, cs->hMenu );
+                if (cs->hMenu) MENU_SetMenu( hwnd, cs->hMenu );
             }
         }
     }
Index: controls/menu.c
===================================================================
RCS file: /home/wine/wine/controls/menu.c,v
retrieving revision 1.168
diff -u -r1.168 menu.c
--- controls/menu.c	17 Sep 2003 04:28:29 -0000	1.168
+++ controls/menu.c	19 Sep 2003 03:17:23 -0000
@@ -3753,11 +3753,12 @@
     return retvalue;
 }
 
-
 /**********************************************************************
- *         SetMenu    (USER32.@)
+ *           MENU_SetMenu
+ *
+ * Set menu for window hWnd (32-bit mode handle; allowed to get menu).
  */
-BOOL WINAPI SetMenu( HWND hWnd, HMENU hMenu )
+BOOL MENU_SetMenu( HWND hWnd, HMENU hMenu )
 {
     TRACE("(%p, %p);\n", hWnd, hMenu);
 
@@ -3766,9 +3767,7 @@
         WARN("hMenu %p is not a menu handle\n", hMenu);
         return FALSE;
     }
-    if (GetWindowLongA( hWnd, GWL_STYLE ) & WS_CHILD) return FALSE;
 
-    hWnd = WIN_GetFullHandle( hWnd );
     if (GetCapture() == hWnd) MENU_SetCapture(0);  /* release the capture */
 
     if (hMenu != 0)
@@ -3782,9 +3781,24 @@
     }
     SetWindowLongA( hWnd, GWL_ID, (LONG_PTR)hMenu );
 
-    if (IsWindowVisible(hWnd))
-        SetWindowPos( hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
-                      SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
+    return TRUE;
+}
+
+/**********************************************************************
+ *         SetMenu    (USER32.@)
+ */
+BOOL WINAPI SetMenu( HWND hWnd, HMENU hMenu )
+{
+    TRACE("(%p, %p);\n", hWnd, hMenu);
+
+    if (GetWindowLongA( hWnd, GWL_STYLE ) & WS_CHILD) return FALSE;
+
+    hWnd = WIN_GetFullHandle( hWnd );
+    if (!MENU_SetMenu( hWnd, hMenu ))
+	return FALSE;
+
+    SetWindowPos( hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
+                  SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
     return TRUE;
 }
 



More information about the wine-patches mailing list