[BCG]如何建立一个BCG属性页对话框

来源:互联网 发布:天盾android数据恢复 编辑:程序博客网 时间:2024/05/22 04:35

原创文章,欢迎转载。转载请注明:转载自 祥的博客

原文链接:http://blog.csdn.net/humanking7/article/details/51262287


1. 新建BCG的Dialog项目

这里写图片描述

2. 添加一个继承CBCGPPropertySheet的类

这里写图片描述

3. 转换程序入口处将Dialog对象换成新建类对象

在入口程序的 BOOL CQFX_BCGAppApp::InitInstance() 中更改。

/* //原来的代码CQFX_BCGAppDlg dlg; //原来的Dialog类对象m_pMainWnd = &dlg;INT_PTR nResponse = dlg.DoModal();*///现在的代码QFXMainPpSheet mainPpSheet; //现在的CBCGPPropertySheet类对象m_pMainWnd = &mainPpSheet;INT_PTR nResponse = mainPpSheet.DoModal();

现在可以删除原来的继承Dialog的类文件

这里写图片描述

4. 设计Page页面

这里写图片描述

这里写图片描述

这里写图片描述

但是,Page1 这个类要继承于类 CBCGPPropertyPage ,所以要修改 Page1.hPage1.cpp

Page1.h 新加代码

#pragma once#include "resource.h"// Page1 对话框class Page1 : public CBCGPPropertyPage{//从CPropertyPage改为CBCGPPropertyPage    DECLARE_DYNAMIC(Page1)public:    Page1();    virtual ~Page1();// 对话框数据    enum { IDD = IDD_PAGE1 };protected:    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持    DECLARE_MESSAGE_MAP()};

Page1.cpp 新加代码

// Page1.cpp : 实现文件//#include "stdafx.h"#include "QFX_BCGApp.h"#include "Page1.h"// Page1 对话框IMPLEMENT_DYNAMIC(Page1, CBCGPPropertyPage)//从CPropertyPage改为CBCGPPropertyPagePage1::Page1()    : CBCGPPropertyPage(Page1::IDD){//从CPropertyPage改为CBCGPPropertyPage}Page1::~Page1(){}void Page1::DoDataExchange(CDataExchange* pDX){    //从CPropertyPage改为CBCGPPropertyPage    CBCGPPropertyPage::DoDataExchange(pDX);}//从CPropertyPage改为CBCGPPropertyPageBEGIN_MESSAGE_MAP(Page1, CBCGPPropertyPage)END_MESSAGE_MAP()// Page1 消息处理程序

QFXMainPpSheet.h 新加代码

//作为主框架的类#pragma once#include "bcgppropertysheet.h"#include "Page1.h"//new Add#include "Page2.h"//new Addclass QFXMainPpSheet :    public CBCGPPropertySheet{    //DECLARE_DYNAMIC(QFXMainPpSheet)//new Addpublic:     ~QFXMainPpSheet(void);    QFXMainPpSheet(CWnd* pParentWnd = NULL);//new Add    Page1 m_Page1;//new Add    Page2 m_Page2;//new Add};

QFXMainPpSheet.cpp 新加代码

#include "StdAfx.h"#include "QFXMainPpSheet.h"QFXMainPpSheet::~QFXMainPpSheet(void){}//new AddQFXMainPpSheet::QFXMainPpSheet( CWnd* pParentWnd /*= NULL*/ ):CBCGPPropertySheet (IDS_CAPTION, pParentWnd)//new Add{// IDS_CAPTION 是窗口标题,是预先添加的资源类型    //这是改变BCG的皮肤,两者必须要同时使用,而且需要预先添加资源图片,这里是IDB_ICONS32    SetLook (CBCGPPropertySheet::PropSheetLook_OutlookBar);//new Add    SetIconsList ( IDB_ICONS32, 32);//new Add    AddPage(&m_Page1);//new Add    AddPage(&m_Page2);//new Add}

5. 运行程序

这里写图片描述

6.程序框架

这里写图片描述

Next····

接着请看[BCG]属性页对话框删除”上一步”…”帮助”等4个按钮

0 0
原创粉丝点击