menu: fix TranslateAccelerator non-menu item behaviour

Huw D M Davies h.davies1 at physics.ox.ac.uk
Tue Mar 16 11:41:21 CST 2004


        Huw Davies <huw at codeweavers.com>
        TranslateAccelerator should only ignore commands when mouse
        capture is in effect or the window is disabled, if the command
        corresponds to a menu item.  Otherwise it should process them
        as normal.
-- 
Huw Davies
huw at codeweavers.com
Index: controls/menu.c
===================================================================
RCS file: /home/wine/wine/controls/menu.c,v
retrieving revision 1.177
diff -u -r1.177 menu.c
--- controls/menu.c	11 Mar 2004 00:41:28 -0000	1.177
+++ controls/menu.c	16 Mar 2004 17:36:17 -0000
@@ -4668,10 +4668,6 @@
  found:
     if (message == WM_KEYUP || message == WM_SYSKEYUP)
         mesg = 1;
-    else if (GetCapture())
-        mesg = 2;
-    else if (!IsWindowEnabled(hWnd))
-        mesg = 3;
     else
     {
         HMENU hMenu, hSubMenu, hSysMenu;
@@ -4686,14 +4682,21 @@
         nPos = cmd;
         if(MENU_FindItem(&hSubMenu, &nPos, MF_BYCOMMAND))
         {
-            SendMessageW(hWnd, WM_INITMENU, (WPARAM)hSysMenu, 0L);
-            if(hSubMenu != hSysMenu)
+            if (GetCapture())
+                mesg = 2;
+            if (!IsWindowEnabled(hWnd))
+                mesg = 3;
+            else
             {
-                nPos = MENU_FindSubMenu(&hSysMenu, hSubMenu);
-                TRACE_(accel)("hSysMenu = %p, hSubMenu = %p, nPos = %d\n", hSysMenu, hSubMenu, nPos);
-                SendMessageW(hWnd, WM_INITMENUPOPUP, (WPARAM)hSubMenu, MAKELPARAM(nPos, TRUE));
+                SendMessageW(hWnd, WM_INITMENU, (WPARAM)hSysMenu, 0L);
+                if(hSubMenu != hSysMenu)
+                {
+                    nPos = MENU_FindSubMenu(&hSysMenu, hSubMenu);
+                    TRACE_(accel)("hSysMenu = %p, hSubMenu = %p, nPos = %d\n", hSysMenu, hSubMenu, nPos);
+                    SendMessageW(hWnd, WM_INITMENUPOPUP, (WPARAM)hSubMenu, MAKELPARAM(nPos, TRUE));
+                }
+                uSysStat = GetMenuState(GetSubMenu(hSysMenu, 0), cmd, MF_BYCOMMAND);
             }
-            uSysStat = GetMenuState(GetSubMenu(hSysMenu, 0), cmd, MF_BYCOMMAND);
         }
         else /* 2. in the window's menu */
         {
@@ -4701,40 +4704,50 @@
             nPos = cmd;
             if(MENU_FindItem(&hSubMenu, &nPos, MF_BYCOMMAND))
             {
-                SendMessageW(hWnd, WM_INITMENU, (WPARAM)hMenu, 0L);
-                if(hSubMenu != hMenu)
+                if (GetCapture())
+                    mesg = 2;
+                if (!IsWindowEnabled(hWnd))
+                    mesg = 3;
+                else
                 {
-                    nPos = MENU_FindSubMenu(&hMenu, hSubMenu);
-                    TRACE_(accel)("hMenu = %p, hSubMenu = %p, nPos = %d\n", hMenu, hSubMenu, nPos);
-                    SendMessageW(hWnd, WM_INITMENUPOPUP, (WPARAM)hSubMenu, MAKELPARAM(nPos, FALSE));
+                    SendMessageW(hWnd, WM_INITMENU, (WPARAM)hMenu, 0L);
+                    if(hSubMenu != hMenu)
+                    {
+                        nPos = MENU_FindSubMenu(&hMenu, hSubMenu);
+                        TRACE_(accel)("hMenu = %p, hSubMenu = %p, nPos = %d\n", hMenu, hSubMenu, nPos);
+                        SendMessageW(hWnd, WM_INITMENUPOPUP, (WPARAM)hSubMenu, MAKELPARAM(nPos, FALSE));
+                    }
+                    uStat = GetMenuState(hMenu, cmd, MF_BYCOMMAND);
                 }
-                uStat = GetMenuState(hMenu, cmd, MF_BYCOMMAND);
             }
         }
 
-        if (uSysStat != (UINT)-1)
-        {
-            if (uSysStat & (MF_DISABLED|MF_GRAYED))
-                mesg=4;
-            else
-                mesg=WM_SYSCOMMAND;
-        }
-        else
+        if (mesg == 0)
         {
-            if (uStat != (UINT)-1)
+            if (uSysStat != (UINT)-1)
             {
-                if (IsIconic(hWnd))
-                    mesg=5;
+                if (uSysStat & (MF_DISABLED|MF_GRAYED))
+                    mesg=4;
                 else
+                    mesg=WM_SYSCOMMAND;
+            }
+            else
+            {
+                if (uStat != (UINT)-1)
                 {
-                    if (uStat & (MF_DISABLED|MF_GRAYED))
-                        mesg=6;
+                    if (IsIconic(hWnd))
+                        mesg=5;
                     else
-                        mesg=WM_COMMAND;
+                    {
+                        if (uStat & (MF_DISABLED|MF_GRAYED))
+                            mesg=6;
+                        else
+                            mesg=WM_COMMAND;
+                    }
                 }
+                else
+                    mesg=WM_COMMAND;
             }
-            else
-                mesg=WM_COMMAND;
         }
     }
 



More information about the wine-patches mailing list