Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable Menu?

Status
Not open for further replies.

TheCrappyProgrammer

Programmer
Sep 17, 2001
41
US
How do I disable and enable a menu item in an MFC Program?
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top