The EnableMenuItem function enables, disables, or grays the specified menu item.
BOOL EnableMenuItem(
HMENU hMenu, |
// handle to menu |
UINT uIDEnableItem, |
// menu item to enable, disable, or gray |
UINT uEnable |
// menu item flags |
); |
Value |
Meaning |
MF_BYCOMMAND |
Indicates that uIDEnableItem gives the identifier of the menu item. If neither the MF_BYCOMMAND nor MF_BYPOSITION flag is specified, the MF_BYCOMMAND flag is the default flag. |
MF_BYPOSITION |
Indicates that uIDEnableItem gives the zero-based relative position of the menu item. |
MF_DISABLED |
Indicates that the menu item is disabled, but not grayed, so it cannot be selected. |
MF_ENABLED |
Indicates that the menu item is enabled and restored from a grayed state so that it can be selected. |
MF_GRAYED |
Indicates that the menu item is disabled and grayed so that it cannot be selected. |
The return value specifies the previous state of the menu item (it is either MF_DISABLED, MF_ENABLED, or MF_GRAYED). If the menu item does not exist, the return value is 0xFFFFFFFF.
An application must use the MF_BYPOSITION flag to specify the correct menu handle. If the menu handle to the menu bar is specified, the top-level menu item (an item in the menu bar) is affected. To set the state of an item in a drop-down menu or submenu by position, an application must specify the handle to the drop-down menu or submenu.
When an application specifies the MF_BYCOMMAND flag, Windows checks all items that open submenus in the menu identified by the specified menu handle. Therefore, unless duplicate menu items are present, specifying the menu handle to the menu bar is sufficient.
The InsertMenu, InsertMenuItem, LoadMenuIndirect, ModifyMenu, and SetMenuItemInfo functions can also set the state (enabled, disabled, or grayed) of a menu item.
GetMenuItemID, InsertMenu, InsertMenuItem, LoadMenuIndirect, ModifyMenu, SetMenuItemInfo, WM_SYSCOMMAND
Questions:
+Why doesn't work EnableMenuItem to gray out an item menu? Ex : void CMainFrame::OnGrayed() { CMenu menu; CMenu* pContextMenu; menu.LoadMenu(IDR_MAINFRAME); resource ID //Get sub menu pContextMenu = menu.GetSubMenu(0); pContextMenu->EnableMenuItem( 2,MF_BYPOSITION|MF_DISABLED|MF_GRAYED); }
file: /Techref/os/win/api/win32/func/src/f18_18.htm, 5KB, , updated: 2002/12/4 17:25, local time: 2024/11/4 15:22,
18.190.253.22:LOG IN ©2024 PLEASE DON'T RIP! THIS SITE CLOSES OCT 28, 2024 SO LONG AND THANKS FOR ALL THE FISH!
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://massmind.org/techref/os/win/api/win32/func/src/f18_18.htm"> EnableMenuItem</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Ashley Roll has put together a really nice little unit here. Leave off the MAX232 and keep these handy for the few times you need true RS232! |
.