请问 CPropertyPage是什么意思?

lanhuo6 2004-08-17 02:54:52
程序中有一句:public CPropertyPage
请问CPropertyPage是什么意思,干什么用的?
...全文
199 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
readi 2004-08-17
  • 打赏
  • 举报
回复
上面是我自己程序里的两个文件,关于CPropertyPage和CPropertySheet,你可以参照着MSDN看一看,若有bug,一定要告诉我哦:)
readi 2004-08-17
  • 打赏
  • 举报
回复
.cpp文件
#include "property.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CPage property page

IMPLEMENT_DYNCREATE(CPage, CPropertyPage)

CPage::CPage() : CPropertyPage(CPage::IDD)
{
//{{AFX_DATA_INIT(CPage)
m_iPcl = 0;
m_iChannel = 0;
m_strCustomCh = _T("");
m_strCustomPcl = _T("");
m_fPower = 0.0f;
m_fCableLoss = 0.0f;
for(int i = 0; i < iITEM_NUM; i++)
{
m_bItem[i] = FALSE;
}
//}}AFX_DATA_INIT
}

CPage::CPage(UINT nIDCaption) : CPropertyPage(CPage::IDD, nIDCaption)
{
//{{AFX_DATA_INIT(CPage)
m_iPcl = 0;
m_iChannel = 0;
m_strCustomCh = _T("");
m_strCustomPcl = _T("");
m_fPower = 0.0f;
m_fCableLoss = 0.0f;
for(int i = 0; i < iITEM_NUM; i++)
{
m_bItem[i] = FALSE;
}
//}}AFX_DATA_INIT}
}

CPage::~CPage()
{
}

void CPage::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPage)
DDX_Radio(pDX, IDC_PCL, m_iPcl);
DDX_Radio(pDX, IDC_CHANNEL, m_iChannel);
DDX_Text(pDX, IDC_CUSTOM_CH, m_strCustomCh);
DDX_Text(pDX, IDC_CUSTOM_PCL, m_strCustomPcl);
DDX_Text(pDX, IDC_POWER, m_fPower);
DDX_Text(pDX, IDC_CABLE_LOSS, m_fCableLoss);
DDX_Check(pDX, IDC_CHECK1, m_bItem[0]);
DDX_Check(pDX, IDC_CHECK2, m_bItem[1]);
for(int i = 0; i < iITEM_NUM; i++)
{
DDX_Check(pDX, IDC_CHECK1+i, m_bItem[0]);
}
//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPage, CPropertyPage)
//{{AFX_MSG_MAP(CPage)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPage message handlers
/////////////////////////////////////////////////////////////////////////////
// CTestSheet

IMPLEMENT_DYNAMIC(CTestSheet, CPropertySheet)

CTestSheet::CTestSheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
}

CTestSheet::CTestSheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
m_Page[GSM] = new CPage(IDS_PAGE_GSM);
m_Page[DCS] = new CPage(IDS_PAGE_DCS);
m_Page[PCS] = new CPage(IDS_PAGE_PCS);
AddPage(m_Page[GSM]);
AddPage(m_Page[DCS]);
AddPage(m_Page[PCS]);
}

CTestSheet::~CTestSheet()
{
delete m_Page[GSM];
delete m_Page[DCS];
delete m_Page[PCS];
}


BEGIN_MESSAGE_MAP(CTestSheet, CPropertySheet)
//{{AFX_MSG_MAP(CTestSheet)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTestSheet message handlers
lanhuo6 2004-08-17
  • 打赏
  • 举报
回复
楼上的哥哥,能说详细点吗,小弟初学vc,谢谢!!!
readi 2004-08-17
  • 打赏
  • 举报
回复
.h文件
#if !defined(AFX_PROPERTY_H__1C4800A3_5759_4D80_9140_CC9A15A1796D__INCLUDED_)
#define AFX_PROPERTY_H__1C4800A3_5759_4D80_9140_CC9A15A1796D__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// property.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CPage dialog
#include "Test Module\TestItem.h"

const int iITEM_NUM = 10;

class CPage : public CPropertyPage
{
DECLARE_DYNCREATE(CPage)

// Construction
public:
CPage(UINT nIDCaption);
CPage();
~CPage();

// Dialog Data
//{{AFX_DATA(CPage)
enum { IDD = IDD_PROPPAGE_LARGE };
int m_iPcl;
int m_iChannel;
CString m_strCustomCh;
CString m_strCustomPcl;
float m_fPower;
float m_fCableLoss;
BOOL m_bItem[iITEM_NUM];
//}}AFX_DATA


// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CPage)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CPage)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()

};

/////////////////////////////////////////////////////////////////////////////
// CTestSheet

class CTestSheet : public CPropertySheet
{
DECLARE_DYNAMIC(CTestSheet)

// Construction
public:
CTestSheet(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
CTestSheet(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);

// Attributes
public:

// Operations
public:

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTestSheet)
//}}AFX_VIRTUAL

// Implementation
public:
CPage* m_Page[TOTAL_BAND];
virtual ~CTestSheet();

// Generated message map functions
protected:
//{{AFX_MSG(CTestSheet)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_PROPERTY_H__1C4800A3_5759_4D80_9140_CC9A15A1796D__INCLUDED_)
readi 2004-08-17
  • 打赏
  • 举报
回复
是MFC中的一个类,用来做tab窗口的一个属性页的
各种消息框的的应用1 创建一个DLG程序 2 添加5个新的对话框资源ID分别为:MsgBoxSimple,MsgBoxOption,MsgBoxCustom,并调整其大小使他们尺寸一样 3 为2中所添加的对话框创建新的类 class CPageSimple : public CPropertyPage class CPageOption : public CPropertyPage class CPageCustom : public CPropertyPage 保存在property.h和property.cpp中。 4 在ShowBmpInPropertyBtnAreaDlg.h中加入 #i nclude "property.h" ... public: CPropertySheet m_MyPropertySheet; //定义属性表变量 CPageSimple m_page1; //以下定义属性页成员变量 CPageOption m_page2; CPageCustom m_page3; 5 在对话框IDD_MESSAGEBOXES模板中加入一个Picture控件,ID设为IDC_PROPSHEET,并调整其大小使其与对话框MsgBoxSimple大小相似 6 在CMessageBoxesDlg::OnInitDialog()中加入 //属性表和属性页的成员变量我已经在头文件中定义过了 //现在把属性页加入到属性表中 m_MyPropertySheet.AddPage(&m_page1); m_MyPropertySheet.AddPage(&m_page2); m_MyPropertySheet.AddPage(&m_page3); //显示非摸态的属性表 m_MyPropertySheet.Create(this, WS_CHILD | WS_VISIBLE, 0); //当对话框搜索下一个Tab项时,WS_EX_CONTROLPARENT标记避免了死循环发生的可能性 //他可以让对话框搜索到属性表中的子窗体控件,就象对话框窗体上的其他普通控件一样。 m_MyPropertySheet.ModifyStyleEx (0, WS_EX_CONTROLPARENT); //允许用户TAB键切换到属性表 m_MyPropertySheet.ModifyStyle( 0, WS_TABSTOP ); //显示属性表 CRect rcSheet; GetDlgItem( IDC_PROPSHEET )->GetWindowRect( &rcSheet ); ScreenToClient( &rcSheet ); m_MyPropertySheet.SetWindowPos( NULL, rcSheet.left-7, rcSheet.top-7, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE ); 7 添加一些按钮,映射各按钮的单击消息,并为响应函数编写代码如下 void CPageSimple::OnSimplestBtn() { MessageBox("这是最最简单的消息框"); } void CPageSimple::OnSimpleBtn() { AfxMessageBox("另一个简单的消息框"); } void CPageOption::OnOkBtn() { MessageBox("仅仅一个按钮确定的消息框", "信息提示消息框", MB_OK|MB_ICONINFORMATION); m_Message = "你只是确认了一下"; UpdateData(FALSE); } void CPageOption::OnOkcancelBtn() { int Response; Response = MessageBox("在这个消息框中你可以选择确定和取消" "\n\n你也可以在此写下对行信息文本" "\n这是你的权利", "选择消息框", MB_OKCANCEL|MB_ICONASTERISK); if( Response == IDOK ) { m_Message = "你选择了确定"; UpdateData(FALSE); } else { m_Message = "你取消了"; UpdateData(FALSE); } } void CPageOption::OnYesnoBtn() { int Response; Response = MessageBox("你吃过了吗?我意思是指从昨天到现今", "信息提示", MB_YESNO|MB_ICONQUESTION); if( Response == IDYES ) { m_Message = "那么,我不需要再给你什么了"; UpdateData(FALSE); } else { m_Message = "那么走吧,正好我也没有吃,咱们一块去吃火锅!"; UpdateData(FALSE); } } void CPageOption::OnYesnocancelBtn() { int Response; Response = MessageBox("当你删除一个目录的时候,或者一个文档改动后," "\n退出程序的时候,这个消息框就会出现", "文档保存提示消息框", MB_YESNOCANCEL|MB_ICONWARNING);

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧