【问题标题】:How to Make CMDIChildWnd as Dockable in MFC?如何使 CMDIChildWnd 在 MFC 中可停靠?
【发布时间】:2014-12-13 15:32:45
【问题描述】:

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

此代码是Button Click事件创建多个Frame....

    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 

【问题讨论】:

    标签: c++ visual-c++ mfc


    【解决方案1】:
    1. 首先创建一个可停靠窗格,要创建一个可停靠窗格,您必须首先从CMDIFrameWndEx 派生。
    2. CMainFrame 中添加该窗格成员
    3. 重要的样式,CBRS_FLOAT_MULTI 使可停靠窗格在附加到选项卡时作为一个单元浮动。 CBRS_LEFT 之类的对齐方式为窗格提供了初始对齐方式。
    4. 选项卡式窗格是一种将窗格相互对接以形成常规选项卡控件的概念,其中包含各个窗格。 使用 AttachToTabWnd() 添加您的窗格

    【讨论】:

    • 感谢您的回复,其实我是 MFC 的新手,所以请您解释一下如何创建它,我不明白您在说什么。上面的代码正在创建多个 MDIChild 框架,但不能相互停靠。我必须在上面的代码中进行哪些更改才能使其作为可停靠以及在按钮单击时创建多个框架
    • 我以为我已经解释得够多了,我没有任何代码示例,谷歌它!但在你这样做之前,我建议你先学习简单的 MFC SDI 应用程序。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-02
    相关资源
    最近更新 更多