3 * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * PROJECT: ReactOS user32.dll
22 * FILE: lib/user32/windows/menu.c
24 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
26 * 09-05-2001 CSH Created
29 /* INCLUDES ******************************************************************/
35 /* TYPES *********************************************************************/
37 typedef struct _MENUITEM
51 } MENUITEM, *PMENUITEM;
53 typedef struct _POPUP_MENU
57 } POPUP_MENU, *PPOPUP_MENU;
59 /* FUNCTIONS *****************************************************************/
62 MenuGetMenu(HMENU hMenu)
65 Menu = (PPOPUP_MENU)hMenu;
70 MenuFindItem(HMENU* hMenu, UINT* nPos, UINT wFlags)
75 if ((ULONG)(*hMenu) == 0xFFFF || (Menu = MenuGetMenu(*hMenu)) == NULL)
79 if (wFlags & MF_BYPOSITION)
81 if ((*nPos) >= Menu->NrItems)
85 return(&Menu->Items[*nPos]);
89 MENUITEM* Item = Menu->Items;
90 for (i = 0; i < Menu->NrItems; i++)
92 if (Item->Id == (*nPos))
97 else if (Item->Type & MF_POPUP)
99 HMENU SubMenu = Item->SubMenu;
100 MENUITEM* SubItem = MenuFindItem(&SubMenu, nPos, wFlags);
113 AppendMenuA(HMENU hMenu,
118 DPRINT("AppendMenuA(hMenu 0x%X, uFlags 0x%X, uIDNewItem %d, "
119 "lpNewItem %s\n", hMenu, uFlags, uIDNewItem, lpNewItem);
120 return(InsertMenuA(hMenu, -1, uFlags | MF_BYPOSITION, uIDNewItem,
125 AppendMenuW(HMENU hMenu,
130 DPRINT("AppendMenuW(hMenu 0x%X, uFlags 0x%X, uIDNewItem %d, "
131 "lpNewItem %S\n", hMenu, uFlags, uIDNewItem, lpNewItem);
132 return(InsertMenuW(hMenu, -1, uFlags | MF_BYPOSITION, uIDNewItem,
137 CheckMenuItem(HMENU hmenu,
144 DPRINT("CheckMenuItem(hmenu 0x%X, uIDCheckItem %d, uCheck %d",
145 hmenu, uIDCheckItem, uCheck);
146 if ((Item = MenuFindItem(&hmenu, &uIDCheckItem, uCheck)) == NULL)
150 Ret = Item->State & MF_CHECKED;
151 if (uCheck & MF_CHECKED)
153 Item->State |= MF_CHECKED;
157 Item->State &= ~MF_CHECKED;
182 CreatePopupMenu(VOID)
245 GetMenuCheckMarkDimensions(VOID)
292 LPMENUITEMINFO lpmii)
303 LPMENUITEMINFO lpmii)
388 LPCMENUITEMINFO lpmii)
399 LPCMENUITEMINFO lpmii)
434 CONST MENUTEMPLATE *lpMenuTemplate)
442 CONST MENUTEMPLATE *lpMenuTemplate)
530 HBITMAP hBitmapUnchecked,
531 HBITMAP hBitmapChecked)
542 LPMENUITEMINFO lpmii)
553 LPMENUITEMINFO lpmii)