views:

192

answers:

2

What would be the easiest way of using commands in the code to programatically disable these two features in an application? Thanks in advance.

A: 

Call CMenu::EnableMenuItem with the appropriate menu items and MF_DISABLED as the second parameter. Here's the documentation.

Traveling Tech Guy
+3  A: 

You could handle the update UI message:

ON_UPDATE_COMMAND_UI(ID_FILE_NEW, OnUpdateFileNew)
ON_UPDATE_COMMAND_UI(ID_FILE_SAVE, OnUpdateFileSave)

...

void CMainFrame::OnUpdateFileNew(CCmdUI *pCmdUI)
{
    pCmdUI->Enable( FALSE );
}

void CMainFrame::OnUpdateFileSave(CCmdUI *pCmdUI)
{
    pCmdUI->Enable( FALSE );
}
Alan
ON_COMMAND_RANGE didn't quite work well for me.
stanigator
Ok, fixed that typo (should have properly read the code after copying from an existing project!)
Alan