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.4 2002/09/07 15:12:45 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 ******************************************************************/
33 /* TYPES *********************************************************************/
35 typedef struct _MENUITEM
49 } MENUITEM
, *PMENUITEM
;
51 typedef struct _POPUP_MENU
55 } POPUP_MENU
, *PPOPUP_MENU
;
57 /* FUNCTIONS *****************************************************************/
60 MenuGetMenu(HMENU hMenu
)
63 Menu
= (PPOPUP_MENU
)hMenu
;
68 MenuFindItem(HMENU
* hMenu
, UINT
* nPos
, UINT wFlags
)
73 if ((*hMenu
) == 0xFFFF || (Menu
= MenuGetMenu(*hMenu
)) == NULL
)
77 if (wFlags
& MF_BYPOSITION
)
79 if ((*nPos
) >= Menu
->NrItems
)
83 return(&Menu
->Items
[*nPos
]);
87 MENUITEM
* Item
= Menu
->Items
;
88 for (i
= 0; i
< Menu
->NrItems
; i
++)
90 if (Item
->Id
== (*nPos
))
95 else if (Item
->Type
& MF_POPUP
)
97 HMENU SubMenu
= Item
->SubMenu
;
98 MENUITEM
* SubItem
= MenuFindItem(&SubMenu
, nPos
, wFlags
);
111 AppendMenuA(HMENU hMenu
,
116 DPRINT("AppendMenuA(hMenu 0x%X, uFlags 0x%X, uIDNewItem %d, "
117 "lpNewItem %s\n", hMenu
, uFlags
, uIDNewItem
, lpNewItem
);
118 return(InsertMenuA(hMenu
, -1, uFlags
| MF_BYPOSITION
, uIDNewItem
,
123 AppendMenuW(HMENU hMenu
,
128 DPRINT("AppendMenuW(hMenu 0x%X, uFlags 0x%X, uIDNewItem %d, "
129 "lpNewItem %S\n", hMenu
, uFlags
, uIDNewItem
, lpNewItem
);
130 return(InsertMenuW(hMenu
, -1, uFlags
| MF_BYPOSITION
, uIDNewItem
,
135 CheckMenuItem(HMENU hmenu
,
142 DPRINT("CheckMenuItem(hmenu 0x%X, uIDCheckItem %d, uCheck %d",
143 hmenu
, uIDCheckItem
, uCheck
);
144 if ((Item
= MenuFindItem(&hmenu
, &uIDCheckItem
, uCheck
)) == NULL
)
148 Ret
= Item
->State
& MF_CHECKED
;
149 if (uCheck
& MF_CHECKED
)
151 Item
->State
|= MF_CHECKED
;
155 Item
->State
&= ~MF_CHECKED
;
180 CreatePopupMenu(VOID
)
243 GetMenuCheckMarkDimensions(VOID
)
290 LPMENUITEMINFOA lpmii
)
301 LPMENUITEMINFOW lpmii
)
386 LPCMENUITEMINFOA lpmii
)
397 LPCMENUITEMINFOW lpmii
)
432 CONST MENUTEMPLATE
*lpMenuTemplate
)
440 CONST MENUTEMPLATE
*lpMenuTemplate
)
528 HBITMAP hBitmapUnchecked
,
529 HBITMAP hBitmapChecked
)
540 LPCMENUITEMINFOA lpmii
)
551 LPCMENUITEMINFOW lpmii
)