最外边的对话框是ADlg,有三个菜单项,对话框里面有两个个tab。page1Dlg和Page2Dlg。其中Page2Dlg里面有个Button。在Onbutton()里面如何操作ADlg的三个菜单项,由不可用变为可用?
GetParent->GetParent->GetMenu();
EnableMenuItem(0, MF_ENABLED | MF_BYPOSITION); 
EnableMenuItem(1, MF_ENABLED | MF_BYPOSITION);
EnableMenuItem(2, MF_ENABLED | MF_BYPOSITION);
error C2227: left of '->GetParent' must point to class/struct/union/generic type
error C2227: left of '->GetMenu' must point to class/struct/union/generic type
error C2660: 'EnableMenuItem' : function does not take 2 arguments
该怎么改啊?麻烦说详细点!谢谢啦!在线急等!

解决方案 »

  1.   

    CWnd* pMain = AfxGetMainWnd();
    if (pMain != NULL)
    {
    // Get the main window's menu
    CMenu* pMenu = pMain->GetMenu();
    pMenu->EnableMenuItem(0, MF_ENABLED | MF_BYPOSITION); 
    pMenu->EnableMenuItem(1, MF_ENABLED | MF_BYPOSITION);
    pMenu->EnableMenuItem(2, MF_ENABLED | MF_BYPOSITION);
    }
    这样可以实现。但是点击了Button,菜单还是灰的,但是可用。鼠标在上面走过就不是灰色的了。怎么回事?
      

  2.   

    CWnd *pWndtab = GetParent();
    CWnd *pWnd = pWndtab->GetParent();
    CMenu *pMenu = pWnd->GetMenu();
    pMenu->EnableMenuItem(0, MF_BYPOSITION | MF_ENABLED);
    pMenu->EnableMenuItem(1, MF_BYPOSITION | MF_ENABLED);
    pMenu->EnableMenuItem(2, MF_BYPOSITION | MF_ENABLED);
    在debug下执行没问题,而且功能实现。在release下执行就出问题。而且问题就出在上面的代码。怎么回事?