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.
19 /* $Id: menu.c,v 1.8 2003/07/10 21:04:32 chorns Exp $
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
);
117 AppendMenuA(HMENU hMenu
,
122 DPRINT("AppendMenuA(hMenu 0x%X, uFlags 0x%X, uIDNewItem %d, "
123 "lpNewItem %s\n", hMenu
, uFlags
, uIDNewItem
, lpNewItem
);
124 return(InsertMenuA(hMenu
, -1, uFlags
| MF_BYPOSITION
, uIDNewItem
,
133 AppendMenuW(HMENU hMenu
,
138 DPRINT("AppendMenuW(hMenu 0x%X, uFlags 0x%X, uIDNewItem %d, "
139 "lpNewItem %S\n", hMenu
, uFlags
, uIDNewItem
, lpNewItem
);
140 return(InsertMenuW(hMenu
, -1, uFlags
| MF_BYPOSITION
, uIDNewItem
,
149 CheckMenuItem(HMENU hmenu
,
156 DPRINT("CheckMenuItem(hmenu 0x%X, uIDCheckItem %d, uCheck %d",
157 hmenu
, uIDCheckItem
, uCheck
);
158 if ((Item
= MenuFindItem(&hmenu
, &uIDCheckItem
, uCheck
)) == NULL
)
162 Ret
= Item
->State
& MF_CHECKED
;
163 if (uCheck
& MF_CHECKED
)
165 Item
->State
|= MF_CHECKED
;
169 Item
->State
&= ~MF_CHECKED
;
209 CreatePopupMenu(VOID
)
318 GetMenuCheckMarkDimensions(VOID
)
390 LPMENUITEMINFO lpmii
)
406 LPMENUITEMINFO lpmii
)
534 LPCMENUITEMINFO lpmii
)
550 LPCMENUITEMINFO lpmii
)
607 CONST MENUTEMPLATE
*lpMenuTemplate
)
620 CONST MENUTEMPLATE
*lpMenuTemplate
)
757 HBITMAP hBitmapUnchecked
,
758 HBITMAP hBitmapChecked
)
774 LPMENUITEMINFO lpmii
)
790 LPMENUITEMINFO lpmii
)