Popup menus should not have a menu item ID under the parent menu
Troy Rollo
wine at troy.rollo.name
Tue Feb 24 00:59:42 CST 2004
The attached patch fixes problems in menus related to the fact that WINE
stores the popup menu handle in the ID field of the MENUITEMINFO structure.
The patch corrects this by preventing the storage of the handle in the ID
field.
To see one manifestation of the problem in action, create a menu which has a
menu item having an ID equal to the menu handle of a popup menu, then grey
the menu item by command. The popup menu will grey.
For example:
HMENU hmenuTop = CreateMenu();
HMENU hmenuNext = CreateMenu();
UINT idItem = (UINT) hmenuNext;
AppendMenu(hmenuNext, MF_ENABLED | MF_STRING, idItem, "Sub-Item");
AppendMenu(hmenuTop, MF_POPUP, (UINT) hmenuNext, "Sub-Menu");
EnableMenuItem(hmenuNext, idItem, MF_BYCOMMAND | MF_GRAYED);
The "Sub-Menu" entry within hmenuTop will be grayed. While this example is
contrived, it is possible that a menu item ID chosen by the application will
just happen to match the value of the menu handle of a sub-menu within the
same menu hierarchy.
-------------- next part --------------
Index: controls/menu.c
===================================================================
RCS file: /home/wine/wine/controls/menu.c,v
retrieving revision 1.176
diff -u -r1.176 menu.c
--- controls/menu.c 17 Feb 2004 20:29:05 -0000 1.176
+++ controls/menu.c 24 Feb 2004 06:44:07 -0000
@@ -1781,8 +1788,19 @@
}
}
- item->wID = id;
- if (flags & MF_POPUP) item->hSubMenu = (HMENU)id;
+ if (flags & MF_POPUP)
+ {
+ item->hSubMenu = (HMENU)id;
+ item->wID = 0; /* Sub-menus don't have IDs */
+ }
+ else
+ {
+ /* FIXME - the code + comment below says we keep the popup entry previously
+ * found here. is this correct? Is there a possibility of an uninitialised
+ * variable here?
+ */
+ item->wID = id;
+ }
if ((item->fType & MF_POPUP) && !(flags & MF_POPUP) )
flags |= MF_POPUP; /* keep popup */
More information about the wine-patches
mailing list