Click to See Complete Forum and Search --> : How do I Enable/Disable Menu Items on a MDI


October 25th, 1999, 09:55 PM
I am having trouble getting the EnableMenuItem function to work properly in either a SDI or MDI application. Basically, I am doing a


GetMenu()->EnableMenuItem( ID_MENU_ITEM, MF_GRAYED )




This works fine in a dialog project, but in a SDI or MDI project, it does not work at all. The functions seem to execute properly, but the menu items do not gray out. Its certainly possible I could just not be placing it in the right place, but I have tried everywhere I can think of. Any help would be appreciated. Please email me at climcla@hotmail.com.

October 25th, 1999, 10:14 PM
Ok, I just found a way to make it work. All I had to do was set the m_bAutoMenuEnable member variable of the CFrameWnd object to false. This made the


GetMenu()->EnableMenuItem( ID_MENU_ITEM, MF_GRAYED );




work properly. If there are other methods please let me know.

Thanks.

Sandrine
October 26th, 1999, 02:02 AM
You can add an update message to your menu item with ClassWizard
And the update function is like:
[ccode]
void CDialog::OnUpdateMenuItem(CCmdUI* pCmdUI)
{
if ( condition )
pCmdUI->Enable(TRUE); // Condition TRUE, the menu item is enable
else
pCmdUI->Enable(FALSE); // else, it is disabled

}

HTH

Sandrine