Oct 4, 2001 #1 TheCrappyProgrammer Programmer Joined Sep 17, 2001 Messages 41 Location US How do I disable and enable a menu item in an MFC Program?
Oct 4, 2001 #2 KeithBrautigam Programmer Joined Nov 4, 2000 Messages 71 Location US In your message map, add an ON_UPDATE_COMMAND_UI macro such as the following: ON_UPDATE_COMMAND_UI(ID_FILE_OPEN, OnUpdateFileOpen) In your header file, declare the function like: afx_msg void OnUpdateFileOpen(CCmdUI* pCmdUI); Then in the actual function body, all you really need to do is to call the Enable function of CCmdUI: void CMainFrame::OnUpdateFileOpen( CCmdUI* pCmdUI ) { // assume m_bEnableMenu is a member of CMainFrame pCmdUI->Enable( m_bEnableMenu ); } For more info on ON_UPDATE_COMMAND_UI and ON_UPDATE_COMMAND_UI_RANGE try searching http://msdn.microsoft.com/ Upvote 0 Downvote
In your message map, add an ON_UPDATE_COMMAND_UI macro such as the following: ON_UPDATE_COMMAND_UI(ID_FILE_OPEN, OnUpdateFileOpen) In your header file, declare the function like: afx_msg void OnUpdateFileOpen(CCmdUI* pCmdUI); Then in the actual function body, all you really need to do is to call the Enable function of CCmdUI: void CMainFrame::OnUpdateFileOpen( CCmdUI* pCmdUI ) { // assume m_bEnableMenu is a member of CMainFrame pCmdUI->Enable( m_bEnableMenu ); } For more info on ON_UPDATE_COMMAND_UI and ON_UPDATE_COMMAND_UI_RANGE try searching http://msdn.microsoft.com/