基于 MFC 的应用程序(以SDI为例)在向导生成以后,将会有一个主框架类(CMainFrame,基于CFrameWnd),一个试图类,程序运行的时候将显示主框架,并在主框架里面显示试图(也就是一个窗体)    现在,我想增加一个窗体,如果不用对话框的话,我想用CFrameWnd,从中派生出一个新的类,在增加一个新的试图类,我希望能够显示新加的框架窗体,并且在客户区显示新的试图类    我不知道这个想法能不行,有没有高手能够指点一下的,    如果有,可不可以给源代码

解决方案 »

  1.   

    我想你大概是想要创建多窗体吧,如下 CMultiFrmApp * pApp;
    pApp=(CMultiFrmApp*)AfxGetApp();
    CDocTemplate* pDocTemplate;
    POSITION pos = pApp->GetFirstDocTemplatePosition();
    pDocTemplate = pApp->GetNextDocTemplate(pos);
    ASSERT(pDocTemplate);

    // Create the new frame
    CMainFrame * pFrame=(CMainFrame*) GetParent();
    CMainFrame* pNewFrame =(CMainFrame *) pDocTemplate->CreateNewFrame(pFrame->GetActiveDocument(),
    (CFrameWnd*)AfxGetMainWnd());
    ASSERT(pNewFrame);

    // Activate the frame and set its active view
    pDocTemplate->InitialUpdateFrame(pNewFrame, NULL);
    ::ShowWindow(pNewFrame->m_hWnd,SW_SHOW);
      

  2.   

    你可以在建一个view来解决