MFC CSplitterWnd的用法
用MFC开发一个软件界面中需要拆分多个试图窗口时,使用CSplitterWnd类
创建步骤:
1.在框架类(CMainFrame)中定义一个CSplitterWnd成员;
2.重载父框架类中CFrameWnd::OnCreateClient函数;
3.在OnCreateClient()函数中调用CSplitterWnd类的Create或CreateStatic()函数;
例子:
CSplitterWnd m_wndSplitter; BOOL CChildFrame::OnCreateClient( LPCREATESTRUCT lpcs,
CCreateContext* pContext)
{ BOOL bCreateSpltr = m_wndSplitter.CreateStatic( this, 2, 1); // COneView and CAnotherView are user-defined views derived from CMDIView
m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(COneView), CSize(0,0),
pContext);
m_wndSplitter.CreateView(1,0,RUNTIME_CLASS(CAnotherView), CSize(0,0),
pContext); return (bCreateSpltr);
} 或者: BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
if (!m_wndSplitter.CreateStatic(this, 1, 2))
return FALSE; if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(160, 200), pContext) ||
!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CTestView), CSize(100, 200), pContext))
{
m_wndSplitter.DestroyWindow();
return FALSE;
}
return TRUE; }
在创建了多个窗口之后,有时为了能够得到其中的某个窗口,进而对其进行操作控制,则:
不能简单使用GetActiveView,可从MainFrame的CSplitterWnd成员得到,如下
CMainFrame* pMF=(CMainFrame*)AfxGetApp()->m_pMainWnd;
CViewRes* pViewRes=(CViewRes*)pMF->m_wndSplitter.GetPane(0,1);
注意:1, 使用CMainFrame,要在调用的cpp文件中包含MainFrame.h
2, 注意在CMainFrame中,m_wndSplitter变量的类型,若定义为protected或private则可能导致不可引用等错误
3, 具体的使用有待测试
相关示例源码链接: http://pan.baidu.com/s/1c0yAbeS 密码: iq8j
MFC CSplitterWnd的用法的更多相关文章
- 【转】MFC下拉列表框的用法
原文网址:http://blog.csdn.net/kinglimy/article/details/6452239 Combo Box (组合框)控件很简单,可以节省空间.从用户角度来看,这个控件是 ...
- MFC之MessageBox用法
一 函数原型及参数 function MessageBox(hWnd: HWND; Text, Caption: PChar; Type: Word): Integer; hWnd:对话框父窗口 ...
- MFC 控件用法
1:IP Control 变量CIPAddressCtrl m_iAddr 关联DDX_Control(pDX,IDC_IPADDRESS1,m_iAddr); 设置地址:m_iAddr.SetAdd ...
- MFC中CFileDialog用法
用CFileDialog选择了一个文件后,使用FILE::fopen打开文件错误,使用 的是相对地址,和王工调试了半天,怎么跟踪也没发现错误,原来如此......... CFileDialog文件选择 ...
- MFC 的SetWindowPos 用法
转自于:http://hi.baidu.com/max_new/blog/item/e2bbe607b1f127c57b8947c0.html 许多软件,特别是占桌面面积不是很大的软件,通常都提供了一 ...
- MFC的定时器OnTimer
本文总结来源出自鸡啄米,感谢鸡啄米.来源:http://www.jizhuomi.com/software/232.html 定时器简介 定时器,可以帮助开发者或者用户定时完成某项任务.在使用定时器时 ...
- MFC ListControl使用方法
在原来博客中有:MF CListControl 简单功能使用 推荐文章:MFC类CtrlList用法 今天又又一次来介绍点新东西:双击击listcontrol 做出响应.当然你能够做的还有非常多,比 ...
- VS2010/MFC编程入门之四十四(MFC常用类:定时器Timer)
前面一节鸡啄米讲了CTime类和CTimeSpan类的使用,本节继续讲与时间有关的定时器.定时器并不是一个类,主要考虑到,提起时间的话就不能不说定时器,所以就把它放到CTime和CTimeSpan之后 ...
- VS2010/MFC编程入门之四十四:定时器Timer
前面一节鸡啄米讲了CTime类和CTimeSpan类的使用,本节继续讲与时间有关的定时器.定时器并不是一个类,主要考虑到,提起时间的话就不能不说定时器,所以就把它放到CTime和CTimeSpan之后 ...
随机推荐
- ARM指令和Thumb指令区别
Thumb指令集 ]的问题而提出的,它具有16为的代码密度.Thumb不是一个完整的体系结构,不能指望处理程序只执行Thumb指令而不支持ARM指令集.因此,Thumb指令只需要支持通用功能,必要时, ...
- (转)Ubuntu中让终端对于历史输出的内容保持足够长
原地址:http://www.crifan.com/ubuntu_terminal_make_retain_long_enough_history_output_content/ Ubuntu下用终端 ...
- 算法_Longest Palindromic Substring(寻找最长回文字串)
题目:Given a string S, find the longest palindromic substring in S. You may assume that the maximum le ...
- dropdownlist绑定和选中
最近在使用dropdownlist控件,对于这个控件,目前我知道的会使用两种方式去绑定数据,现在将这两种方式分享给大家: 现在是后台数据绑定 protected void BindCarID() { ...
- 火星A+B..(不贴代码了)
还是A+B Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
- 二维码识别:Halcon与C++中多字节环境下的字节编码格式设置和转换
Halcon环境下可通过设置set_system(‘filename_encoding’, ‘utf8’),可以将二维码的识别结果解析出汉字. VS环境下则需要将utf8转换成gbk格式.代码如下: ...
- 关于onclick中的event对象和element对象
event.srcElement:引发事件的目标对象,常用于onclick事件. event.fromElement:引发事件的对象源,常用于onmouseout和onmouseover事件. eve ...
- hdu Buy the Ticket
import java.math.BigInteger; import java.util.*; public class Main { public static void main(String ...
- Android 圆形按钮实现
项目中用到的圆形按钮,做个半天,用sharp形式实现,样式代码如下: <Button android:id="@+id/btn_5" android:layout_width ...
- 安装开源项目 MultiType (基于 RecyclerView)出现的各种问题 -- 自己的第一篇博客
一.引入开源项目的方式 使用开源项目 MultiType 的两种方式: 1.maven引入:在主Module 的 build.gradle 中加入 dependencies { ...... comp ...