MFC程序员的WTL指南(9)属性页与向导
2006-07-22 22:03:05 来源:WEB开发网核心提示: CWizIntroPage::CWizIntroPage() :CPropertyPageImpl<CWizIntroPage>( IDS_WIZARD_TITLE ){}当这个页面激活时,字符串IDS_WIZARD_TITLE ("PSheets Options W
CWizIntroPage::CWizIntroPage() :
CPropertyPageImpl<CWizIntroPage>( IDS_WIZARD_TITLE )
{
}
当这个页面激活时,字符串IDS_WIZARD_TITLE ("PSheets Options Wizard")将出现在向导的标题栏。OnSetActive()仅仅使“下一步”按钮可用:
int CWizIntroPage::OnSetActive()
{
SetWizardButtons ( PSWIZB_NEXT );
return 0;
}
为了实现一个向导,我们需要创建一个类COptionsWizard,还要在主窗口添加菜单Tools|Wizard。COptionsWizard类的构造函数和CAppPropertySheet类的构造函数一样,只是设置必要的样式标志和添加页面。
class COptionsWizard : public CPropertySheetImpl<COptionsWizard>
{
public:
// Construction
COptionsWizard ( HWND hWndParent = NULL );
// Maps
BEGIN_MSG_MAP(COptionsWizard)
CHAIN_MSG_MAP(CPropertySheetImpl<COptionsWizard>)
END_MSG_MAP()
// Property pages
CWizIntroPage m_pgIntro;
};
COptionsWizard::COptionsWizard ( HWND hWndParent ) :
CPropertySheetImpl<COptionsWizard> ( 0U, 0, hWndParent )
{
SetWizardMode();
AddPage ( m_pgIntro );
}
CMainFrame类的Tools|Wizard菜单处理函数是这个样子:
void CMainFrame::OnOptionsWizard ( UINT uCode, int nID, HWND hwndCtrl )
{
COptionsWizard wizard;
wizard.DoModal();
}
这就是向导的效果:
更多精彩
赞助商链接