本文介绍了如何拆分CDockablePane?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将CDockablePane分为两部分,就像VS2010 IDE中的类视图"一样?
预先感谢!
How can I split a CDockablePane into two parts, just like the "Class View" in VS2010 IDE?
Thanks in advance!
推荐答案
将CSplitterWndEx扩展如下:
class CPaneSplitter : public CSplitterWndEx
{
public :
BOOL AddWindow(int row, int col, CWnd* pWin,CString clsName,
DWORD dwStyle,DWORD dwStyleEx, SIZE sizeInit);
};
将以下成员添加到MyDockablePaneClass
CTreeCtrl m_wndTree
CListCtrl m_wndList
CPaneSplitter wndSplitter
MyDockablePaneClass的OnCreate看起来像这样:
int MyDockablePaneClass::OnCreate(LPCREATESTRUCT lp)
{
if(CDockablePane::OnCreate(lp)==-1)
return -1;
DWORD dwStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT
| TVS_HASBUTTONS |TVS_EDITLABELS;
DWORD dwStyleEx = 0;
m_wndSplitter.CreateStatic(this,2,1);
if(!m_wndSplitter.AddWindow(0,0,&m_wndTree,WC_TREEVIEW,dwStyle,
dwStyleEx,CSize(100,100)))
return -1;
dwStyle = WS_CHILD | WS_VISIBLE | LVS_ICON | LVS_SHAREIMAGELISTS;
dwStyleEx = 0;
if(!m_wndSplitter.AddWindow(1,0,&m_wndList,WC_LISTVIEW,dwStyle
,dwStyleEx,CSize(100,100)))
return -1;
if(!m_toolbar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_REFTREE))
{
TRACE0("Failed to create RefTreePane Toolbar Control\n");
return -1;
}
m_toolbar.LoadToolBar(IDR_REFTREE, 0, 0, TRUE /* Is locked */);
m_toolbar.SetPaneStyle(m_toolbar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY);
m_toolbar.SetPaneStyle(m_toolbar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT));
m_toolbar.SetOwner(this);
// All commands will be routed via this control , not via the parent frame:
m_toolbar.SetRouteCommandsViaFrame(FALSE);
return 0;
}
为OnSize添加追随者,如下所示
void MyDockablePaneClass::OnSize(UINT type,int cx,int cy)
{
CDockablePane::OnSize(type, cx, cy);
int cyTlb = m_toolbar.CalcFixedLayout(FALSE, TRUE).cy;
CRect rectClient;
GetClientRect(rectClient);
m_toolbar.SetWindowPos(NULL, rectClient.left, rectClient.top, rectClient.Width()
, cyTlb,SWP_NOACTIVATE | SWP_NOZORDER);
m_wndSplitter.SetRowInfo(0,(cy-cyTlb)/2,25);
m_wndSplitter.SetRowInfo(1,(cy-cyTlb)/2,25);
m_wndSplitter.SetWindowPos(NULL,rectClient.left
, rectClient.top + cyTlb
, rectClient.Width() , rectClient.Height() - cyTlb , SWP_NOZORDER | SWP_NOACTIVATE);
}
请注意,如果您没有工具栏,请在onSize处理程序中添加用于工具栏定位的处理程序,并删除代码并假定cyTlb = 0
祝你好运
这篇关于如何拆分CDockablePane?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!