How can I with code make a menu Item inactive at any time????
Thanks
Printable View
How can I with code make a menu Item inactive at any time????
Thanks
When a menu is about to be displayed by your application, your mainframe class will receive a WM_INITMENUPOPUP message.
Override this function and you can then call EnableMenuItem(ID_OF_ITEM, MF_DISABLED) on the Cmenu* pointer given you. Note, I am quoting this from memory, so my details might not be exactly correct...
HTH
Roger Allen
Here u go. Use the MF_GRAYED to disable, and the MF_ENABLED to enable it.
HMENU thisMenu = GetMenu(hwnd);
// This specifies the 3rd pop-up menu
HMENU thisSubMenu = GetSubMenu(thisMenu,2);
bool bReturn;
// IDM_MENUITEM is the menu item to disable
bReturn = EnableMenuItem(thisSubMenu, IDM_MENUITEM, MF_GRAYED);
Hope this helps.
Todd