MFC创建属性表单

来源:互联网 发布:网络数字矩阵 编辑:程序博客网 时间:2024/05/18 12:04

1、插入3个属性页对话框资源。

2、分别给3个属性页创建一个新类。

3、创建一个属性表单类。

4、分别定义3个属性表单对象,把对象添加到属性表单中。

5、设置属性表单的 样式,并启用OnSetActive()虚函数 设置属性表单向导

6、创建一个按钮命令响应函数,显示属性表单。


/////////////////////////////////////////////////////////////////////////////// CPropSheet#include "Prop1.h"#include "Prop2.h"#include "Prop3.h"#include "PropSheet.h"/* 分别定义属性表页对象  */CProp1 prop1;CProp2 prop2;CProp3 prop3;IMPLEMENT_DYNAMIC(CPropSheet, CPropertySheet)CPropSheet::CPropSheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage):CPropertySheet(nIDCaption, pParentWnd, iSelectPage){/* 把属性表单页添加到属性表单中 */ AddPage(&prop1); AddPage(&prop2); AddPage(&prop3);}CPropSheet::CPropSheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage):CPropertySheet(pszCaption, pParentWnd, iSelectPage){/* 把属性表单页添加到属性表单中 */AddPage(&prop1); AddPage(&prop2); AddPage(&prop3);}


#include "PropSheet.h"void CMy1Dlg::OnPropertysheet() {// TODO: Add your control notification handler code hereCPropSheet propSheet("属性页");//propSheet.SetWizardMode();//设置属性表单为横向模式。 如果不要就是纵向显示propSheet.DoModal();//显示属性表单对话框(模态对话框)}



#include "PropSheet.h"BOOL CProp1::OnSetActive() {// TODO: Add your specialized code here and/or call the base class//设置属性表单横向向导((CPropSheet *)GetParent())->SetWizardButtons(PSWIZB_NEXT);return CPropertyPage::OnSetActive();}

// CProp2 message handlers#include "PropSheet.h"BOOL CProp2::OnSetActive() {// TODO: Add your specialized code here and/or call the base class//设置属性表单横向向导((CPropSheet *)GetParent())->SetWizardButtons(PSWIZB_NEXT|PSWIZB_BACK);return CPropertyPage::OnSetActive();}


// CProp3 message handlers#include "PropSheet.h"BOOL CProp3::OnSetActive() {// TODO: Add your specialized code here and/or call the base class//设置属性表单横向向导((CPropSheet *)GetParent())->SetWizardButtons(PSWIZB_BACK);return CPropertyPage::OnSetActive();}