如何在MDI中遍历所有ChildFrame,怎样隐藏某一个ChildFrame?因为我要自己排列显示各ChildFrame的位置,并且根据条件要显示或隐藏某一个或几个ChildFrame,请教各位高手,如何实现这样的要求呢?

解决方案 »

  1.   

    CDocTemplate::GetFirstDocPosition,Use the POSITION value as an argument to CDocTemplate::GetNextDoc to iterate through the list of documents associated with the template.
    to each document use
    CDocument::GetFirstViewPosition which returns a POSITION value that can be used for iteration with the CDocument::GetNextView function. 
      

  2.   

    我以为大家都知道CView有一个public属性叫m_hWnd.
    我也以为大家都知道通过sdk函数
    BOOL ShowWindow(
      HWND hWnd,     // handle to window
      int nCmdShow   // show state
    );
    操作窗口。
    实际上还应该枚举所有文档模板。
    MDI程序具有一个或多个文档模板,
    每个文档模板具有一个或多个文档实例,
    每个文档实例具有一个或多个视图。楼主会用就行了。
      

  3.   

    给你一段代码吧: // 关闭所有已打开的窗口
    POSITION pos;
    CEVITDocTemplate *p = NULL; CString strTitle;
    pos = GetFirstDocTemplatePosition();
    while(pos != NULL)
    {
    p = (CEVITDocTemplate*)GetNextDocTemplate(pos);
    if(p->m_pFrame != NULL)
    {
    p->m_pFrame->SendMessage(WM_CLOSE);
    }
    }你可能会奇怪m_pFrame哪来的?
    CEVITDocTemplate是我从CMultiDocTemplate派生来的,m_pFrame是CChildFrame,而且我还重载了CMultiDocTemplate::CreateNewFrameCFrameWnd* CEVITDocTemplate::CreateNewFrame(CDocument *pDoc, CFrameWnd *pOther)
    {
    m_pFrame = CMultiDocTemplate::CreateNewFrame(pDoc, pOther);
    return m_pFrame;
    }OK,不?