resent: menu capture tracking fix

Andreas Mohr andi at
Tue Apr 1 14:43:19 CST 2003

[I don't know why this wasn't applied, without any comment;
resending it]

Hi all,

the menu code has been annoying me to no end sometimes. Now I guess I
know why: SetMenu() completely removed mouse capture right in between
running in the menu tracking loop!
This lead to menu tracking getting stuck right in between menus.

I really don't know why this code was there, but I guess it must have
served some purpose (other than making menu support completely unusable for
several programs ;), so in case anyone knows, just tell me.

A sample program can be found at

Andreas Mohr

Index: controls/menu.c
RCS file: /home/wine/wine/controls/menu.c,v
retrieving revision 1.161
diff -u -r1.161 menu.c
--- controls/menu.c	16 Jan 2003 01:17:34 -0000	1.161
+++ controls/menu.c	26 Feb 2003 01:20:11 -0000
@@ -2898,7 +2898,7 @@
     MENU_SetCapture(0);  /* release the capture */
     /* If dropdown is still painted and the close box is clicked on
        then the menu will be destroyed as part of the DispatchMessage above.
        This will then invalidate the menu handle in mt.hTopMenu. We should
@@ -3767,8 +3767,13 @@
     if (GetWindowLongA( hWnd, GWL_STYLE ) & WS_CHILD) return FALSE;
     hWnd = WIN_GetFullHandle( hWnd );
-    if (GetCapture() == hWnd) MENU_SetCapture(0);  /* release the capture */
+#ifdef FUBAR_CODE
+    /* if a program calls SetMenu() in between, then this will totally disrupt
+     * the capture set by MENU_TrackMenu during menu tracking!! */
+    if (GetCapture() == hWnd) MENU_SetCapture(0);  /* release the capture */
     if (hMenu != 0)
         LPPOPUPMENU lpmenu;

Andreas Mohr                        Stauferstr. 6, D-71272 Renningen, Germany

More information about the wine-patches mailing list