Bob Moore's Coding Tips

50. I've disabled a menu item on my MFC program using EnableMenuItem, but it won't go gray. Why?

You have fallen foul of the MFC automatic menu enable/disable mechanisms. MFC will automatically enable any menu item which has a handler when the menu item is popped up.

So your call to EnableMenuItem (FALSE) did work, but it was promptly undone again when the menu was popped up.

You need to define an UPDATE_COMMAND_UI handler for the menu item via ClassWizard.