Vulkan

[VC]切分窗口成两半,一半放控件,一半画图


VC++中创建切分窗口

1.使用向导创建SDI窗体,一切默认值


2.在CMainFrame类中增加切分控件成员:

类视图中右键CMainFrame->添加变量:CSplitterWnd m_wndSplitter;

3.添加一个新Dialog资源,修改属性:

解决方案资源管理器---资源文件右击--添加--资源--点击DIALOG---右击出现的DIALOG---属性,如下方法修改
  Border:none
  Control:True
  ID:IDD_D_DIALOG   //这里随便取个ID
  Style:child
 删除  确定 取消 按钮<----------------右击DIALOG,删除

4.双击你添加的Dialog,添加一个新类,名为  CSplitterLeft  下面中下拉框中选择继承自CFormView类


5.在CMainFrame类的OnCreateClient方法(若没有,右击类-属性-“重写”找到“CreateClient”-添加)中增加如下代码,


BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
{
 // TODO: Add your specialized code here and/or call the base class
 m_wndSplitter.CreateStatic(this, 1, 2);
 m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CSplitterLeft), CSize(100, 100), pContext);       //括号中Dialog的类
 m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(C******View), CSize(100, 100), pContext);//括号中VIEW区类名
 return TRUE;
}

6同时需要在MainFrm.cpp中增加所加视图的头文件包括


#include "*****View.h"  <--工程的视图区view类头文件
#include "SplitterLeft.h"  <--对话框类头文件

7.如果编译时出现文档类的missing storage-class or type specifiers 错误,


在view类的头文件中包含文档类的头文件

#include "****Doc.h"              //如PEReaderDoc.h

posted on 2012-01-07 17:03  Vulkan  阅读(133)  评论(0编辑  收藏  举报

导航