那用GetParentFrame()和AfxGetApp()->m_pMainWnd
得出的是什么?

解决方案 »

  1.   

    quace:
    AfxGetMainWnd()跟GetParentFrame()和AfxGetApp()->m_pMainWnd
    得出来的是一样的啊,不是CMainFrame的指针
    我说的是SDI啊,不是MDI;
      

  2.   

    CMainFrame *pw=(CMainFrame *)AfxGetMainWnd();
      

  3.   

    在CView里CMainFrame* mainFrame = (CMainFrame*)GetParent()->GetParent();
      

  4.   

    应该对AfxGetApp()进行显式的类型转换,转换成你自己的派生类。派生类的指针转换成基类指针时,引用的数据成员是基类的成员,只有在转换成派生类的指针后才能指向派生类的数据成员。你用GetParentFrame和AfxGetApp()->m_pMainWnd得到的数据成员即为基类的成员,而非你自己的派生类的成员。