VC实现对话框窗口任意分割
2019/7/10 23:08:27
本文主要是介绍VC实现对话框窗口任意分割,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
个人认为简单问题最好就是直接贴源代码,一看就明白,说来说去反而弄不清楚,那我就少废话了,自己看吧,注释很清楚。
先来张图片
1. 新建一个MFC对话框程序MySplitterDlg。 再插入两个Dialog资源 ,这里一定要选择IDD_FORMVIEW类别的对话框,分别新建类CMyFormView0 和CMyFormView1,基类别选CDialog,一定要选择CFormView。
2. CMySplitterDlg中增加WM_CREATE的消息响应,编辑OnCreate()
int CMySplitterDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CDialog::OnCreate(lpCreateStruct) == -1) return -1; // Because the CFRameWnd needs a window class, we will create a new one. I just copied the sample from MSDN Help. // When using it in your project, you may keep CS_VREDRAW and CS_HREDRAW and then throw the other three parameters. //需要注册窗口类 CString strMyClass = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW, ::LoadCursor(NULL, IDC_ARROW), (HBRUSH) ::GetStockObject(WHITE_BRUSH), ::LoadIcon(NULL, IDI_APPLICATION)); // Create the frame window with "this" as the parent m_pMyFrame = new CFrameWnd; m_pMyFrame->Create(strMyClass,"", WS_CHILD, CRect(0,0,300,300), this); m_pMyFrame->ShowWindow(SW_SHOW); // and finally, create the splitter with the frame as the parent m_cSplitter.CreateStatic(m_pMyFrame,1, 2); //在Frame里切分视图窗口为1×2,就是一行两列 m_cSplitter.CreateView(0,0, RUNTIME_CLASS(CMyFormView0), CSize(100,100), NULL);//第一行一列 m_cSplitter.CreateView(0,1, RUNTIME_CLASS(CMyFormView1), CSize(100,100), NULL);//第一行二列 return 0; }
3. 在CMySplitterDlg::OnInitDialog()中显示Frame
int CMySplitterDlg::OnInitDialog() { CDialog::OnInitDialog(); GetWindowRect(&cRect); ScreenToClient(&cRect); m_pMyFrame->MoveWindow(&cRect); m_pMyFrame->ShowWindow(SW_SHOW); return TRUE; }
这篇关于VC实现对话框窗口任意分割的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-07-05feign默认connecttimeout和readtimeout是多少-icode9专业技术文章分享
- 2024-07-05idea控制台,日志太多,导致部分想看得日志被刷走 搜不到-icode9专业技术文章分享
- 2024-07-05The server selected protocol version Tls10 is not accepted by client preferences [TLs12]-icode9专业技术文章分享
- 2024-07-05怎么清理项目缓存-icode9专业技术文章分享
- 2024-07-04安装 Eyoucms详细图文教程-icode9专业技术文章分享
- 2024-07-04ueditor 复制文章时,图片的链接是一个下载图片地址,该如何处理?-icode9专业技术文章分享
- 2024-07-04怎样判断host有没有对wordpress有缓存呢-icode9专业技术文章分享
- 2024-07-04具有编译功能的系统make后,无法ssh连接-icode9专业技术文章分享
- 2024-07-04make后如何升级ssh-icode9专业技术文章分享
- 2024-07-03微信支付提示下单账户与支付账户不一致-icode9专业技术文章分享