关于浮动窗口以及分割窗口的问题
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
CSize BarSize; //工具条大小
BarSize.cx = 200;
BarSize.cy = 150;
RECT rt;
if (!(m_DockBar1.Create(_T("m_DockBar1"), this, BarSize, TRUE, WS_CHILD)))
{
TRACE0("Failed to create m_TreeViewBar\n");
return -1;
}
if (!(m_DockBar2.Create(_T("m_DockBar2"), this, BarSize, TRUE, WS_CHILD)))
{
TRACE0("Failed to create m_PictureBar\n");
return -1;
}
m_DockBar1.SetBarStyle(m_DockBar1.GetBarStyle() | CBRS_TOOLTIPS| CBRS_SIZE_FIXED); // TODO: Delete these three lines if you don't want the toolbar to
m_DockBar2.SetBarStyle(m_DockBar2.GetBarStyle() | CBRS_TOOLTIPS| CBRS_SIZE_FIXED); // TODO: Delete these three lines if you don't want the toolbar to
m_DockBar1.EnableDocking(CBRS_ALIGN_ANY);
m_DockBar2.EnableDocking(CBRS_ALIGN_ANY);
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
//DockControlBar(&m_wndToolBar);
rt.top = 0;
rt.bottom = 150;
rt.left = 20;
rt.right = 200;
DockControlBar(&m_DockBar1, AFX_IDW_DOCKBAR_LEFT, &rt);
rt.top = 150;
rt.bottom = 300;
DockControlBar(&m_DockBar2, AFX_IDW_DOCKBAR_LEFT, &rt);
return 0;
}
请大家帮忙看看,我想要的结果就是左边有两个竖排的浮动窗口,但是有时候却变成并列的两个?
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// CG: The following block was added by the Splitter Bar component.
{
// if (!m_wndSplitter.Create(this,
// 2, 1, // TODO: adjust the number of rows, columns
// CSize(10, 10), // TODO: adjust the minimum pane size
// pContext))
if(!m_wndSplitter.CreateStatic(this, 2, 1))
{
TRACE0("Failed to create splitter bar ");
return FALSE; // failed to create
}
CRect rt;
GetClientRect(&rt);
m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CDockTestView), CSize(rt.Width(), rt.Height() / 2), pContext);
m_wndSplitter.CreateView(1, 0, RUNTIME_CLASS(CMyView), CSize(rt.Width(), rt.Height() / 2), pContext);
return TRUE;
}
}
右边的窗体想居中平均分割两个,但是却总是无法居中分割?
请大家帮忙,在线等待!解决马上给分,不够可以再给!谢谢!