VC实现对话框窗口任意分割
2015-06-30 11:36
656 查看
个人认为简单问题最好就是直接贴源代码,一看就明白,说来说去反而弄不清楚,那我就少废话了,自己看吧,注释很清楚。
先来张图片
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; }
您可能感兴趣的文章:
相关文章推荐
- 过滤淘宝网弹出窗口
- 分割超大Redis数据库例子
- 三个不同文件停顿二秒弹出不同窗口的批处理
- C#中父窗口和子窗口之间控件互操作实例
- jQuery窗口、文档、网页各种高度的精确理解
- VC实现获取当前正在运行的进程
- vc中SendMessage自定义消息函数用法实例
- VC实现让关闭按钮成灰色不可用的方法
- VC++中的字体设置方法详解
- VC程序设计中CreateProcess用法注意事项
- VC实现批量删除指定文件的方法
- vc中使用SendMessage自定义消息函数
- vc提示unexpected end of file found的原因分析
- vc获取计算机名和ip地址的方法
- VC6.0实现读取Excel数据的方法
- VC下通过系统快照实现进程管理的方法
- C# Winform窗口之间传值的多种方法浅析
- WPF实现渐变淡入淡出的登陆窗口效果
- php把大写命名转换成下划线分割命名
- 一个JavaScript用逗号分割字符串实例