Alexandre Julliard : user32: Reimplement MENU_FindSubMenu on the 16-bit side using only exported functions .

Alexandre Julliard julliard at winehq.org
Wed Dec 23 10:04:09 CST 2009


Module: wine
Branch: master
Commit: 00e75f2b9eb117b95e9024c16fa916c3b3f7460d
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=00e75f2b9eb117b95e9024c16fa916c3b3f7460d

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Dec 22 17:00:12 2009 +0100

user32: Reimplement MENU_FindSubMenu on the 16-bit side using only exported functions.

---

 dlls/user32/controls.h |    1 -
 dlls/user32/menu.c     |    2 +-
 dlls/user32/msg16.c    |   22 ++++++++++++++++++++--
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/dlls/user32/controls.h b/dlls/user32/controls.h
index f9752ee..9392cbe 100644
--- a/dlls/user32/controls.h
+++ b/dlls/user32/controls.h
@@ -158,7 +158,6 @@ extern void MENU_TrackMouseMenuBar( HWND hwnd, INT ht, POINT pt ) DECLSPEC_HIDDE
 extern void MENU_TrackKbdMenuBar( HWND hwnd, UINT wParam, WCHAR wChar ) DECLSPEC_HIDDEN;
 extern UINT MENU_DrawMenuBar( HDC hDC, LPRECT lprect,
                                 HWND hwnd, BOOL suppress_draw ) DECLSPEC_HIDDEN;
-extern UINT MENU_FindSubMenu( HMENU *hmenu, HMENU hSubTarget ) DECLSPEC_HIDDEN;
 extern void MENU_EndMenu(HWND) DECLSPEC_HIDDEN;
 
 /* nonclient area */
diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c
index 9205146..0f083ff 100644
--- a/dlls/user32/menu.c
+++ b/dlls/user32/menu.c
@@ -656,7 +656,7 @@ static MENUITEM *MENU_FindItem( HMENU *hmenu, UINT *nPos, UINT wFlags )
  * *hmenu in case it is found in another sub-menu.
  * If the submenu cannot be found, NO_SELECTED_ITEM is returned.
  */
-UINT MENU_FindSubMenu( HMENU *hmenu, HMENU hSubTarget )
+static UINT MENU_FindSubMenu( HMENU *hmenu, HMENU hSubTarget )
 {
     POPUPMENU *menu;
     UINT i;
diff --git a/dlls/user32/msg16.c b/dlls/user32/msg16.c
index 0866875..672e4a2 100644
--- a/dlls/user32/msg16.c
+++ b/dlls/user32/msg16.c
@@ -587,6 +587,24 @@ static HANDLE16 convert_handle_32_to_16(UINT_PTR src, unsigned int flags)
     return dst;
 }
 
+static int find_sub_menu( HMENU *hmenu, HMENU16 target )
+{
+    int i, pos, count = GetMenuItemCount( *hmenu );
+
+    for (i = 0; i < count; i++)
+    {
+        HMENU sub = GetSubMenu( *hmenu, i );
+        if (!sub) continue;
+        if (HMENU_16(sub) == target) return i;
+        if ((pos = find_sub_menu( &sub, target )) != -1)
+        {
+            *hmenu = sub;
+            return pos;
+        }
+    }
+    return -1;
+}
+
 /**********************************************************************
  *	     WINPROC_CallProc16To32A
  */
@@ -825,8 +843,8 @@ LRESULT WINPROC_CallProc16To32A( winproc_callback_t callback, HWND16 hwnd, UINT1
         if((LOWORD(lParam) & MF_POPUP) && (LOWORD(lParam) != 0xFFFF))
         {
             HMENU hmenu = HMENU_32(HIWORD(lParam));
-            UINT pos = MENU_FindSubMenu( &hmenu, HMENU_32(wParam) );
-            if (pos == 0xffff) pos = 0;  /* NO_SELECTED_ITEM */
+            int pos = find_sub_menu( &hmenu, wParam );
+            if (pos == -1) pos = 0;
             wParam = pos;
         }
         ret = callback( hwnd32, msg, MAKEWPARAM( wParam, LOWORD(lParam) ),




More information about the wine-cvs mailing list