Menus [4/6]: Fix HiliteMenuItem

Michael Kaufmann hallo at michael-kaufmann.ch
Wed Apr 19 14:43:15 CDT 2006


Changelog:

- HiliteMenuItem: Don't move the selection and don't clear already 
hilited menu items
- Support unhiliting of items
- Support items in popup menus (just set the MF_HILITE flag like Windows)
-------------- next part --------------
--- menu.c	2006-04-19 21:09:51.000000000 +0200
+++ menu-new.c	2006-04-19 21:09:48.000000000 +0200
@@ -3604,12 +3604,33 @@
                                 UINT wHilite )
 {
     LPPOPUPMENU menu;
+    HDC hdc;
+
     TRACE("(%p, %p, %04x, %04x);\n", hWnd, hMenu, wItemID, wHilite);
+    if (!hWnd || !IsWindow(hWnd)) return FALSE;
     if (!MENU_FindItem( &hMenu, &wItemID, wHilite )) return FALSE;
     if (!(menu = MENU_GetMenu(hMenu))) return FALSE;
-    if (menu->FocusedItem == wItemID) return TRUE;
-    MENU_HideSubPopups( hWnd, hMenu, FALSE );
-    MENU_SelectItem( hWnd, hMenu, wItemID, TRUE, 0 );
+
+    if ((menu->wFlags & MF_POPUP) || GetMenu(hWnd) != hMenu)
+    {
+        menu->items[wItemID].fState &= ~MFS_HILITE;
+        menu->items[wItemID].fState |= (wHilite & MFS_HILITE);
+    }
+    else
+    {
+        if ((menu->items[wItemID].fState & MFS_HILITE) == (wHilite & MFS_HILITE))
+        {
+            return TRUE;
+        }
+
+        menu->items[wItemID].fState &= ~MFS_HILITE;
+        menu->items[wItemID].fState |= (wHilite & MFS_HILITE);
+
+        hdc = GetDCEx( hWnd, 0, DCX_CACHE | DCX_WINDOW );
+        SelectObject( hdc, get_menu_font( (menu->items[wItemID].fState & MFS_DEFAULT) ));
+        MENU_DrawMenuItem( hWnd, hMenu, hWnd, hdc, &menu->items[wItemID], menu->Height, TRUE, ODA_DRAWENTIRE );
+        ReleaseDC( hWnd, hdc );
+    }
     return TRUE;
 }
 


More information about the wine-patches mailing list