概述:創(chuàng)建一個(gè)屬性表單,首先創(chuàng)建一個(gè)CPropertySheet對(duì)象;為每一個(gè)屬性表單創(chuàng)建一個(gè)CPropertyPage對(duì)象,在CPropertySheet類中;在CPropertySheet類的構(gòu)造函數(shù)中添加AddPage函數(shù)添加每個(gè)屬性頁(yè);最后在菜單函數(shù)中調(diào)用DoModal函數(shù)來(lái)顯示一個(gè)靜態(tài)屬性表單。屬性頁(yè)
是被添加屬性表單的,也就是說(shuō),屬性表單是屬性頁(yè)的父窗口。因此,可以通過(guò)GetParent()函數(shù)獲得屬性頁(yè)父窗口的指針,即屬性表單的
指針,但要經(jīng)過(guò)類型轉(zhuǎn)換
步驟:
1、創(chuàng)建一個(gè)或多個(gè)屬性頁(yè),基類為CPropertyPage。
class CPropSet1 : public CPropertyPage
{
// Dialog Data
//{{AFX_DATA(CPropSet1)
enum { IDD = IDD_PROP_SET1 };
int m_MAXVALUEX2;
int m_MINVALUEX2;
//}}AFX_DATA
}
2、建立CProp表單:基類為CPropertySheet。
CPropSheet::CPropSheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
AddPage(&m_propSet1); //決定page順序
AddPage(&m_propSet2);
}
3、菜單函數(shù):
void CDataView::OnPropsheet()
{
// TODO: Add your command handler code here
CPropSheet propSheet("參數(shù)設(shè)置"); //表單名稱,其他為缺省變量
propSheet.m_propSet1.m_MAXVALUEX2=m_XValueMax;
propSheet.m_propSet1.m_MINVALUEX2=m_XValueMin;
if( IDOK==propSheet.DoModal())
{
m_ChartCtrl1.EnableRefresh(false);
m_XValueMax=propSheet.m_propSet1.m_MAXVALUEX2;
m_XValueMin=propSheet.m_propSet1.m_MINVALUEX2;
m_ChartCtrl1.GetBottomAxis()->SetMinMax(m_XValueMin,m_XValueMax);
m_ChartCtrl1.EnableRefresh(true);
}
}
4、建立向?qū)В?br>首先在調(diào)用屬性表單對(duì)象的DoModal函數(shù)之前,調(diào)用SetWizardMode函數(shù)。
propSheet.SetWizardMode();
然后通過(guò)SetWizardButtons函數(shù)設(shè)置向?qū)?duì)話框上的按鈕。
((CPropSheet*)GetParent())->SetWizardButtons(PSWIZB_NEXT);
((CPropSheet*)GetParent())->SetWizardButtons(PSWIZB_NEXT | PSWIZB_BACK);
((CPropSheet*)GetParent())->SetWizardButtons(PSWIZB_BACK | PSWIZB_FINISH);
注意點(diǎn):需改文字種類和類型。