void CTestDlg::OnBnClickedChange()
{
// TODO: 在此添加控件通知处理程序代码
CString str
if(GetDlgItemText(IDC_CHANGE,str),str==_T("收缩<<")){
SetDlgItemText(IDC_CHANGE,_T("扩展>>"))
}else{
SetDlgItemText(IDC_CHANGE,_T("收缩<<"))
}
static CRect largeRect
static CRect smallRect
if(largeRect.IsRectNull()){
CRect rectSeparator
GetWindowRect(&largeRect)
GetDlgItem(IDC_SEPARATOR)->GetWindowRect(&rectSeparator)
smallRect.left=largeRect.left
smallRect.right=largeRect.right
smallRect.top=largeRect.top
smallRect.bottom=rectSeparator.bottom
}
if(_T("收缩<<")==str){
SetWindowPos(NULL,0,0,smallRect.Width(),smallRect.Height(),SWP_NOMOVE |
SWP_NOZORDER)
}
else{
SetWindowPos(NULL,0,0,largeRect.Width(),largeRect.Height(),SWP_NOMOVE |
SWP_NOZORDER)
}
}
xxxx::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext){
/基配/---------------------------------------------------------
//m_wndSpliter,m_wndSpliter2均为成员变量,CSplitterWnd类别
//CTest1,CTest2,CTest3均继承于CView
//---------------------------------------------------------
//第一次分割左右两个窗口
m_wndSpliter.CreateStatic( this, 1, 2 )
m_wndSpliter.CreateView( 0,1, RUNTIME_CLASS(CTest2), CSize(0,0), pContext )
m_wndSpliter.SetColumnInfo( 0, 700, 50 )
//第二次分割上下搏中指两个窗口
m_wndSpliter2.CreateStatic( &m_wndSpliter, 2, 1, WS_CHILD|WS_VISIBLE, m_wndSpliter.IdFromRowCol(0,0) )
m_wndSpliter2.CreateView( 0, 0, RUNTIME_CLASS(CTest1), CSize(0,0), pContext )
m_wndSpliter2.CreateView( 1, 0, RUNTIME_CLASS(CTest3), CSize(0,0), pContext )
m_wndSpliter2.SetRowInfo( 0, 300, 50 )
return TRUE/培大/重要
}
利用CSplitterWnd构造函数分割闷橘:1、创建动态切分窗口
2、创建静态友罩枝好敏切分窗口
BOOL CreateView (int row,int col,CruntimeClass* pViewClass,SIZE sizeinit,CcreateContext* pContext)为实现复杂的分割窗口,需要在Cmainfrm.h中增加多个CSplitterWnd: 而多个视图之间通信只能让他们都与文档类通信。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)