您的位置:首页 > 其它

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

2016-04-27 16:39 375 查看
原创文章,欢迎转载。转载请注明:转载自 祥的博客

原文链接:/article/7763582.html

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改为CBCGPPropertyPage

Page1::Page1()
: CBCGPPropertyPage(Page1::IDD)
{//从CPropertyPage改为CBCGPPropertyPage

}

Page1::~Page1()
{
}

void Page1::DoDataExchange(CDataExchange* pDX)
{
//从CPropertyPage改为CBCGPPropertyPage
CBCGPPropertyPage::DoDataExchange(pDX);
}

//从CPropertyPage改为CBCGPPropertyPage
BEGIN_MESSAGE_MAP(Page1, CBCGPPropertyPage)
END_MESSAGE_MAP()

// Page1 消息处理程序


QFXMainPpSheet.h 新加代码

//作为主框架的类
#pragma once
#include "bcgppropertysheet.h"
#include "Page1.h"//new Add
#include "Page2.h"//new Add

class QFXMainPpSheet :
public CBCGPPropertySheet
{
//DECLARE_DYNAMIC(QFXMainPpSheet)//new Add

public:

~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 Add
QFXMainPpSheet::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.程序框架

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: