menus and MDI

  • Thread starter Thread starter ouech
  • Start date Start date
O

ouech

hi,

i'm still having troubles with my menus

the EnableMenuItem function doesn't seem to work at all
in a MDI. i'm doing exactly the same thing as i did when
i coded a dialog based App with a menu, but it worked.

i just want to disable and gray commands in the menu.
And even when i disable it in the properties in the
ressource editor, it does nothing.

and the stranger is that when i use ModifyMenu,
it transform the menu item into a separator!!.

am i smoking too much or Frames don't let me do anything
with the menu?

i almost forgot but it does the same with my popup menu which
is created with CMenu::LoadMenu and is not a part of my frame...

i give a piece of code but it's has i explain :

BOOL CMdiApp::InitInstance()
{
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;

CMenu *menu = pMainFrame->GetMenu()->GetSubMenu(0);

menu->EnableMenuItem(IDM_BOUNCE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
menu->ModifyMenu(IDM_HELLO, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);

pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
m_pMainWnd = pMainFrame;

// load the two static menus
return TRUE;
}

thanks,
 
i'm still having troubles with my menus
the EnableMenuItem function doesn't seem to work at all
in a MDI.

Enable/disable the menu item in the command's ON_UPDATE handler -
which is executed just prior to the menu being displayed. See "Message
Handling and Mapping" in MSDN for more information.

Dave
 
Enable/disable the menu item in the command's ON_UPDATE handler -
which is executed just prior to the menu being displayed. See "Message
Handling and Mapping" in MSDN for more information.

Dave

thanks, it was that. i could do it by setting m_bAutoMenuEnable to FALSE
wich prevents the ON_UPDATE mechanism.
 
Back
Top