如何使CMDIChildWnd在MFC中可停靠

How to Make CMDIChildWnd as Dockable in MFC?

本文关键字:停靠 MFC 何使 CMDIChildWnd      更新时间:2023-10-16

我想让CMDIChildWnd成为可停靠的....我的代码创建窗口框架时单击功能区按钮,我想以选项卡式格式停靠所有窗口,当我放置拖动我的框架时显示停靠管理器格式[DT_SMART]...

此代码是按钮单击事件创建多个帧...。

    pDocTemplate_New1 = new CMultiDocTemplate ( IDR_RiboonCFormViewTYPE, 
                RUNTIME_CLASS(CRiboonCFormViewTestDoc),
                RUNTIME_CLASS(CChildFrame), // custom MDI child frame
                RUNTIME_CLASS(CDepartement));
    AfxGetApp () -> AddDocTemplate (pDocTemplate_New1); 
    // Create a new child window 
    CMDIChildWnd * pMDIActive = MDIGetActive (); // get the pointer of the currently active child window 
    //CDocument * pDoc = (CDocument *) pMDIActive-> GetActiveDocument (); // get the document pointer 
    CMDIChildWnd * pNewFrame = (CMDIChildWnd *) (pDocTemplate_New1 -> CreateNewFrame (NULL, NULL));
    pNewFrame->EnableDocking(CBRS_ALIGN_ANY);
    EnableDocking(CBRS_ALIGN_ANY);
    // Create a new frame window 
    if (pNewFrame == NULL) 
    { 
        AfxMessageBox("new window can not be established ", MB_OK, 0); 
    } 
    pDocTemplate_New1 -> InitialUpdateFrame (pNewFrame, NULL); // display window 
    MDITile (MDITILE_HORIZONTAL); // tile multiple windows 
    首先创建可停靠窗格,
  1. 要创建可停靠窗格,必须先从CMDIFrameWndEx派生。
  2. CMainFrame中添加该窗格成员
  3. 重要的样式CBRS_FLOAT_MULTI使可停靠窗格在附加到选项卡时作为一个单元浮动。像 CBRS_LEFT 这样的对齐样式为窗格提供初始对齐方式。
  4. 选项卡式窗格是将窗格
  5. 相互停靠以形成内部具有单个窗格的常规选项卡控件的概念。使用 AttachToTabWnd () 添加窗格