关于用CSplitterWnd分割View的一点总结

1.在要分割的View中添加OnCreate消息响应函数 ;

2.分割函数:

int CUserManagerSplitterView::OnCreate(LPCREATESTRUCTlpCreateStruct)
... {
if(CView::OnCreate(lpCreateStruct)==-1)
return-1;

if(!m_wndUserSplitter.CreateStatic(this,1,2))
...{
returnFALSE;
}


BOOLbRet
=m_wndUserSplitter.CreateView(0,0,RUNTIME_CLASS(CUserLeftPanView),CSize(200,100),NULL);
if(!bRet)
...{
TRACE0(
"Failedtocreateleftuserpan!");
returnFALSE;
}


bRet
=m_wndUserSplitter.CreateView(0,1,RUNTIME_CLASS(CUserRightPanView),CSize(100,100),NULL);
if(!bRet)
...{
TRACE0(
"Failedtocreaterightuserpan!");
returnFALSE;
}


m_wndUserSplitter.RecalcLayout();


return0;
}

3.添加OnSize()响应,显示SplitterWnd:

void CUserManagerSplitterView::OnSize(UINTnType, int cx, int cy)
... {
CView::OnSize(nType,cx,cy);

if(this->m_hWnd!=NULL)
...{
CRectrect;
GetClientRect(
&rect);

if(m_wndUserSplitter.GetSafeHwnd()!=NULL)
...{
m_wndUserSplitter.MoveWindow(
&rect);
}


}


}

3.如果要Left Pan 与 Right Pan 可相互通信,参考以下代码:

// 在CUserLeftPanView中定义:CUserRightPanView*m_pUserRightPanView;
// 然后在OnCreate后面添加:

CUserLeftPanView
* pUserLeftPanView = (CUserLeftPanView * )m_wndSplitter.GetPane( 0 , 0 );
pUserLeftPanView
-> m_pRightPanView = (CUserRightPanView * )m_wndSplitter.GetPane( 0 , 1 );

4.分割Frame方法一样;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值