Revised menu patch

Michael Kaufmann hallo at michael-kaufmann.ch
Wed Sep 8 12:23:05 CDT 2004


Hi Uwe

>Micheal,
>
>can we perhaps create a test case, that mimics the Delphi behaviour and
>succeeds on WinXX but fails on Wine? Then the behaviour is well documented
>and there is less reason to not fix it while breaking another test.
>  
>

Yes, that's a good idea! I've attached a test case that fails only on 
WINE. It doesn't really imitate Delphi's behavior, but it tests the root 
cause of the bug.

Delphi basically executes this code:

DestroyMenu(GetMenu(myWindow));
HMENU newMenu = CreateMenu();  /* WINE creates a menu with the same 
handle as the deleted menu! */
if (GetMenu(myWindow) != newMenu)
{
    SetMenu(myWindow, newMenu);
}

SetMenu never gets called on WINE! The menu is not initialized properly.

Windows 9x doesn't have this bug because it returns NULL on 
GetMenu(WindowWithDestroyedMenu). My patch does this too.
Windows 2000 doesn't have this bug because it deletes the menu when it's 
not needed anymore and so doesn't create a new menu with the same handle.

Regards

Michael
-------------- next part --------------
Index: dlls/user/tests/win.c
===================================================================
RCS file: /home/wine/wine/dlls/user/tests/win.c,v
retrieving revision 1.33
diff -u -r1.33 win.c
--- dlls/user/tests/win.c	26 Aug 2004 18:33:40 -0000	1.33
+++ dlls/user/tests/win.c	8 Sep 2004 16:57:12 -0000
@@ -1605,7 +1605,7 @@
 static void test_SetMenu(HWND parent)
 {
     HWND child;
-    HMENU hMenu, ret;
+    HMENU hMenu, hMenu2, ret;
     BOOL is_win9x = GetWindowLongW(parent, GWL_WNDPROC) == 0;
 
     hMenu = CreateMenu();
@@ -1622,6 +1622,12 @@
     /* This test fails on Win9x */
     if (!is_win9x)
         ok(ret == hMenu, "unexpected menu id %p\n", ret);
+
+    hMenu2 = CreateMenu();
+    ok(ret != hMenu2, "hMenu is deleted but still assigned to a window, CreateMenu should return a different handle");
+    ok(GetMenuItemCount(ret) == -1, "hMenu is deleted and should be non-existent from the application's point of view");
+    DestroyMenu(hMenu2);
+        
     ok(SetMenu(parent, 0), "SetMenu(0) on a top level window should not fail\n");
     test_nonclient_area(parent);
 


More information about the wine-devel mailing list