还在苦苦敲代码开发APP?你out啦! 试试积木搭建APP吧~

MDI CDockablePane使用总结

来源:个人博客     2016-01-19 17:33:11    人气:     我有话说( 0 人参与)

最近做项目使用到了MFC的CDockablePane进行布局,下面将应用心得以九个例子进行总结如下:1. CFrameWndEx 在框架类的头文件中定义一个CDo...

最近做项目使用到了MFC的CDockablePane进行布局,下面将应用心得以九个例子进行总结如下:

1. CFrameWndEx  在框架类的头文件中定义一个CDockablePane的数组

CDockablePane m_Panes[5];//一个CDockablePane的数组

2. CFrameWndEx:: OnCreate() 在Create函数中自动生成了以下代码,对MFC比较熟悉的这里就不讲了:

CMFCPopupMenu::SetForceMenuFocus(FALSE);
InitUserToolbars(NULL, uiFirstUserToolBarId, uiLastUserToolBarId);
EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, 0, ID_VIEW_TOOLBAR);
CDockingManager::SetDockingMode(DT_SMART);
EnableAutoHidePanes(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);

(1) 第一种情况

if (!m_Panes[0].Create(_T("Pane 0"), this, CRect(0, 0, 200, 100), TRUE, 1000,
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI))
{return FALSE;}
m_Panes[0].EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_Panes[0]);// LEFT


(2)第二种情况

if (!m_Panes[0].Create(_T("Pane 0"), this, CRect(0, 0, 200, 100), TRUE, 1000,
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI))
{return FALSE;}
if (!m_Panes[1].Create(_T("Pane 1"), this, CRect(0, 0, 200, 100), TRUE, 1001,
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI))
{return FALSE;}
m_Panes[0].EnableDocking(CBRS_ALIGN_ANY);
m_Panes[1].EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_Panes[1]);// BOTTOM
DockPane(&m_Panes[0]);// LEFT

 

(3)第三种情况

 

if (!m_Panes[0].Create(_T("Pane 0"), this, CRect(0, 0, 200, 100), TRUE, 1000,
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI))
{return FALSE;}
if (!m_Panes[1].Create(_T("Pane 1"), this, CRect(0, 0, 200, 100), TRUE, 1001,
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI))
{return FALSE;}
m_Panes[0].EnableDocking(CBRS_ALIGN_ANY);
m_Panes[1].EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_Panes[0]);// LEFT
DockPane(&m_Panes[1]);// BOTTOM

 

(4)第四种情况

if (!m_Panes[0].Create(_T("Pane 0"), this, CRect(0, 0, 200, 100), TRUE, 1000,
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI))
{return FALSE;}
if (!m_Panes[1].Create(_T("Pane 1"), this, CRect(0, 0, 200, 100), TRUE, 1001,
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI))
{return FALSE;}
m_Panes[0].EnableDocking(CBRS_ALIGN_ANY);
m_Panes[1].EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_Panes[0]);// LEFT
DockPane(&m_Panes[1]);// LEFT
// 注意这里,将0放在1上面
m_Panes[0].DockToWindow(&m_Panes[1], CBRS_TOP);

 

(5)第五种情况

if (!m_Panes[0].Create(_T("Pane 0"), this, CRect(0, 0, 200, 100), TRUE, 1000,
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI))
{return FALSE;}
if (!m_Panes[1].Create(_T("Pane 1"), this, CRect(0, 0, 200, 100), TRUE, 1001,
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI))
{return FALSE;}
m_Panes[0].EnableDocking(CBRS_ALIGN_ANY);
m_Panes[1].EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_Panes[0]);// LEFT
DockPane(&m_Panes[1]);// LEFT
CDockablePane* pTabbedBar = NULL;
// 放到同一个选项卡中,并默认选择1
m_Panes[1].AttachToTabWnd(&m_Panes[0], DM_SHOW, TRUE, &pTabbedBar);

 

(6)第六种情况

if (!m_Panes[0].Create(_T("Pane 0"), this, CRect(0, 0, 200, 100), TRUE, 1000,
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI))
{return FALSE;}
if (!m_Panes[1].Create(_T("Pane 1"), this, CRect(0, 0, 200, 100), TRUE, 1001,
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI))
{return FALSE;}
if (!m_Panes[2].Create(_T("Pane 2"), this, CRect(0, 0, 200, 100), TRUE, 1002,
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI))
{return FALSE;}
m_Panes[0].EnableDocking(CBRS_ALIGN_ANY);
m_Panes[1].EnableDocking(CBRS_ALIGN_ANY);
m_Panes[2].EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_Panes[0]);// LEFT
DockPane(&m_Panes[1]);// LEFT
DockPane(&m_Panes[2]);// LEFT
m_Panes[0].DockToWindow(&m_Panes[2], CBRS_TOP);
CDockablePane* pTabbedBar = NULL;
m_Panes[1].AttachToTabWnd(&m_Panes[0], DM_SHOW, TRUE, &pTabbedBar);

 

(7)第七种情况

if (!m_Panes[0].Create(_T("Pane 0"), this, CRect(0, 0, 200, 100), TRUE, 1000,
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI))
{return FALSE;}
if (!m_Panes[1].Create(_T("Pane 1"), this, CRect(0, 0, 200, 100), TRUE, 1001,
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI))
{return FALSE;}
m_Panes[0].EnableDocking(CBRS_ALIGN_ANY);
m_Panes[1].EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_Panes[0]);// BOTTOM
DockPane(&m_Panes[1]);// BOTTOM
CDockablePane* pTabbedBar = NULL;
m_Panes[0].DockToWindow(&m_Panes[1], CBRS_LEFT);

 

(8)第八种情况

if (!m_Panes[0].Create(_T("Pane 0"), this, CRect(0, 0, 200, 100), TRUE, 1000,
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI))
{return FALSE;}
if (!m_Panes[1].Create(_T("Pane 1"), this, CRect(0, 0, 200, 100), TRUE, 1001,
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI))
{return FALSE;}
if (!m_Panes[2].Create(_T("Pane 2"), this, CRect(0, 0, 200, 100), TRUE, 1002,
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI))
{return FALSE;}
if (!m_Panes[3].Create(_T("Pane 3"), this, CRect(0, 0, 200, 100), TRUE, 1003,
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI))
{return FALSE;}
if (!m_Panes[4].Create(_T("Pane 4"), this, CRect(0, 0, 200, 100), TRUE, 1004,
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI))
{return FALSE;}
m_Panes[0].EnableDocking(CBRS_ALIGN_ANY);
m_Panes[1].EnableDocking(CBRS_ALIGN_ANY);
m_Panes[2].EnableDocking(CBRS_ALIGN_ANY);
m_Panes[3].EnableDocking(CBRS_ALIGN_ANY);
m_Panes[4].EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_Panes[0]);// BOTTOM
DockPane(&m_Panes[1]);// BOTTOM
DockPane(&m_Panes[2]);// LEFT
DockPane(&m_Panes[3]);// LEFT
DockPane(&m_Panes[4]);// RIGHT
CDockablePane* pTabbedBar = NULL;
m_Panes[0].DockToWindow(&m_Panes[1], CBRS_LEFT);
m_Panes[3].AttachToTabWnd(&m_Panes[2], DM_SHOW, TRUE, &pTabbedBar);

 

(9)第九种情况

if (!m_Panes[0].Create(_T("Pane 0"), this, CRect(0, 0, 200, 100), TRUE, 1000,
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI))
{return FALSE;}
if (!m_Panes[1].Create(_T("Pane 1"), this, CRect(0, 0, 200, 100), TRUE, 1001,
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI))
{return FALSE;}
if (!m_Panes[2].Create(_T("Pane 2"), this, CRect(0, 0, 200, 100), TRUE, 1002,
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI))
{return FALSE;}
if (!m_Panes[3].Create(_T("Pane 3"), this, CRect(0, 0, 200, 100), TRUE, 1003,
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI))
{return FALSE;}
if (!m_Panes[4].Create(_T("Pane 4"), this, CRect(0, 0, 200, 100), TRUE, 1004,
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI))
{return FALSE;}
m_Panes[0].EnableDocking(CBRS_ALIGN_ANY);
m_Panes[1].EnableDocking(CBRS_ALIGN_ANY);
m_Panes[2].EnableDocking(CBRS_ALIGN_ANY);
m_Panes[3].EnableDocking(CBRS_ALIGN_ANY);
m_Panes[4].EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_Panes[0]);// BOTTOM
DockPane(&m_Panes[1]);// BOTTOM
DockPane(&m_Panes[2]);// LEFT
DockPane(&m_Panes[3]);// LEFT
DockPane(&m_Panes[4]);// RIGHT
CDockablePane* pTabbedBar = NULL;
m_Panes[1].AttachToTabWnd(&m_Panes[0], DM_SHOW, TRUE, &pTabbedBar);
m_Panes[3].AttachToTabWnd(&m_Panes[2], DM_SHOW, TRUE, &pTabbedBar);


CDockablePane MDI

本文源自互联网,采用知识共享署名-非商业性使用 4.0 国际许可协议进行许可,
版权归原作者,如有问题请联系service@tsingfun.com (编辑:admin)
分享到: