如何为切分的窗口使用属性页(从fromview继承)
2013-04-20 13:21
337 查看
前言
这篇文章是讲怎么样在切分出来的窗口(一半opengl绘图,一半对话框)中使用属性页。。。记下来以便以后用到!以下方法是参考了两篇10多年前的文章,主要是第二篇。。
http://www.vckbase.com/index.php/wv/211
http://www.codeguru.com/cpp/controls/propertysheet/article.php/c591/Creating-a-Property-Sheet-Inside-a-Form-View.htm
MFC中opengl环境配置:http://blog.csdn.net/shenlan282/article/details/8821861
使用CSplitterWnd切分窗口:http://blog.csdn.net/shenlan282/article/details/7183832
接下来就是讲怎么样在左半部分切分的窗口中使用属性页:
初始界面如图:
参照第二篇文章,详细步骤如下:
第一步: Create a "place holder" control in your form view's template
打开切分出来的左半部分的资源对话框,打开 工具箱,拖动一个picture control控件添加到对话框中,该控件ID为 IDC_PLACEHOLDER第二步:Create a derived CPropertySheet class
切换到类视图模式,右击工程名,类向导((这里不要点击 添加-类)),右上角有个添加类,添加一个 CMyPropertySheet 类,继承自CPropertySheet修改生成的类文件.h 的构造函数的参数,只保留一个
CMyPropSheet(CWnd*
pParentWnd =NULL);
并且在CPP文件中把构造函数的实现改为:
CMyPropSheet::CMyPropSheet(CWnd*
pParentWnd):CPropertySheet(AFX_IDS_APP_TITLE,pParentWnd)
{
}
第三步:Add
a pointer to the derived property sheet class in your form view class
在切分窗口类SplitterLeft中添加一个成员变量CMyPropertySheet * m_pMyPropSheet,
这里应该讲 CMyPropertySheet
类的头文件#include一下
第四步:Add code in CMyFormView::OnInitialUpdate() to create your
property sheet
重载SplitterLeft的OnInitialUpdate() 方法(右击该类-属性-重载-找到该方法-添加),添加以下代码// create and asociated the property sheet with the "place holder" window CWnd* pwndPropSheetHolder = GetDlgItem(IDC_PLACEHOLDER); m_pMyPropSheet = new CMyPropertySheet(pwndPropSheetHolder); if (!m_pMyPropSheet->Create(pwndPropSheetHolder, WS_CHILD | WS_VISIBLE, 0)) { delete m_pMyPropSheet; m_pMyPropSheet = NULL; return; } // fit the property sheet into the place holder window, and show it CRect rectPropSheet; pwndPropSheetHolder->GetWindowRect(rectPropSheet); m_pMyPropSheet->SetWindowPos(NULL, 0, 0, rectPropSheet.Width(), rectPropSheet.Height(), SWP_NOZORDER | SWP_NOACTIVATE);
第五步:Create the pages by deriving from CPropertyPage
添加N个资源对话框,这些对话框用来作为propertyPage,每个对话框的Caption改为你想显示的名字,Style为child,Border为thin,只选中TitileBar复选框,去掉其他复选框。为每个对话框添加不同的ID_。
为每个对话框添加一个类(右键该资源对话框,添加类)继承自CPropertyPage,比如为Page1,Page2
第六步:Add the page's objects as member variables to the propery sheet class
为 CMyPropertySheet 类添加子对话框的类对象:右击CMyPropertySheet类-添加变量
如
Page1 m_page1;
Page2 m_page2;
第七步:Add page insertion code in the derived property sheet's constructor
在CMyPropertySheet 类的实现中把这Page类对象add进去CMyPropSheet::CMyPropSheet(CWnd* pParentWnd) :CPropertySheet(AFX_IDS_APP_TITLE, pParentWnd) { AddPage(&m_page1); AddPage(&m_page2); ...... }
第八步:Bingo~~~
注:转载请注明出处!
相关文章推荐
- 带切分的窗口中如何获取某块view的指针
- 总算解决如何在view上应用CSplitterWnd来切分窗口
- 使用WindowManager.addView()方法增加的悬浮窗口,如何固定屏幕显示方向?
- 继承android.view.View自定义view,使用画笔绘制view示例
- 视图控制器父类是使用Xib创建的,子类如何继承父类的样式
- 如何使用Storyboard创建UIPageViewController
- 使用webview如何做超时判断
- 如何使用ClipDrawable实现ImageView图片切换动画
- 编译错误-----RealView MDK中国版中如何使用静态函数指针
- 【Unity】脚本没有继承MonoBehaviour 如何使用Destroy
- QT如何让子窗口不继承父窗口的边框、背景等风格
- MFC--滚动视图窗口(CScrollView)使用双缓冲问题
- Android如何使用WebView访问https的网站
- 使用addView方法时,如何保持已有动态控件位置不被改变
- 如何在控制台程序中使用窗口
- android中如何使用ViewRootImpl这个类
- JSP设计模式基础:View Helper模式——学习如何使用View Helper模式使得Model数据适应表现层的需要(2)
- 如何实现不能被继承的C++的类,且能正常使用
- Android中如何使用ViewPager实现类似laucher左右拖动效果 3ff8
- 6.如何使用CardView制作卡片布局效果