您的位置:首页 > 其它

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

2008-05-24 17:47 417 查看
1.在要分割的View中添加OnCreate消息响应函数 ;

2.分割函数:


int CUserManagerSplitterView::OnCreate(LPCREATESTRUCT lpCreateStruct)




...{


if (CView::OnCreate(lpCreateStruct) == -1)


return -1;





if(!m_wndUserSplitter.CreateStatic(this, 1, 2))




...{


return FALSE;


}




BOOL bRet = m_wndUserSplitter.CreateView(0, 0, RUNTIME_CLASS(CUserLeftPanView), CSize(200, 100), NULL);


if(!bRet)




...{


TRACE0("Failed to create left user pan!");


return FALSE;


}




bRet = m_wndUserSplitter.CreateView(0, 1, RUNTIME_CLASS(CUserRightPanView), CSize(100, 100), NULL);


if(!bRet)




...{


TRACE0("Failed to create right user pan!");


return FALSE;


}




m_wndUserSplitter.RecalcLayout();







return 0;


}



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


void CUserManagerSplitterView::OnSize(UINT nType, int cx, int cy)




...{


CView::OnSize(nType, cx, cy);




if(this->m_hWnd != NULL)




...{


CRect rect;


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方法一样;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: