2. 或者,重载OnCreateClient函数
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
CCreateContext* pContext)
{
return m_wndSplitter.Create(this,
2, 2, // TODO: 调整行数和列数
CSize(10, 10), // TODO: 调整最小窗格大小
pContext)
}
你只要用一个picture control作为分割线,然后当点击某个按钮时,用SetWindowPos来改变对话框的大小就可以达到分割窗口的目的我给你段示例代码你参考下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)
}
}
点击右键,你d出个菜单,里面有你说的两个选项,这个你应该会。如果用户点击了分割的菜单项,你就在view区域画一条线作为分割线即可,这样不就分割了吗?线画在什么位置,这个由你具体决定。然后你需要在每次重绘的时候,如果用户选择了分割,你需要把分割线给画出来。如果你想灵活些,就把mfc扔了,窗口自己建,想怎么处理就怎么处理,不用为了添加个功能都要费好大劲儿。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)