VisualC程序设计教程第六章属性单CPropertySheet.ppt
文本预览下载声明
第6章 属性单(CPropertySheet) 和属性页(CPropertyPage) 6.1 属性单和属性页相关类 6.2 创建属性单和属性页程序 6.3 创建向导属性单应用程序 6.1 属性单和属性页相关类 MFC库提供了两个支持属性单的重要类:CPropertySheet类和CPropertyPage类,分别对属性单和属性页进行了封装. CPropertySheet类是CWnd类的一个派生类,作为属性页对话框的窗口框架出现,主要实现管理各个属性页面的作用,一个属性单可以包含一个CPropertySheet类(或者其派生类)的对象和多个CPropertyPage类(或者其派生类)的对象。 1.CPropertySheet类 CPropertySheet类的对象表示属性表,通常由一个或多个属性页对象组成。 PropertySheet类不是CDialog类的派生类,但是在使用该类时却和CDialog类非常相似:首先运行CPropertySheet类的构造函数,然后调用DoModal()函数实现一个模式属性单对话框,或者调用Creat()函数实现一个非模式属性单对话框。 (1)CPropertySheet方法 其原型为: CPropertySheet( ); CPropertySheet ( UINT nIDCaption,,CWnd *pParentWnd=NULL,UINT iSelectPage=0); CPropertySheet (LPCTSTR pszCaption,CWnd *pParentWnd=NULL,UINT iSelectPage=0); (2)Construct方法 其原型为: void Construct(UINT nIDCaption,CWnd *pParentWnd=NULL,UINT iSelectPage=0); void Construct(LPCTSTR pszCaption,CWnd *pParentWnd=NULL,UINT iSelectPage=0); (3)GetActivePage方法 其原型为: CPropertyPage* GetActivePage( ) const; (4)SetActivePage方法 其原型为: BOOL SetActivePage( int nPage ); BOOL SetActivePage( CPropertyPage* pPage ); (5)DoModal方法 其原型为: virtual int DoModal( ); (6)Create方法 其原型为: BOOL Create( CWnd* pParentWnd = NULL, DWORD dwStyle = (DWORD)–1, DWORD dwExStyle = 0 ); (7)AddPage方法 其原型为: void AddPage( CPropertyPage *pPage ); (8)RemovePage方法 其原型为: void RemovePage( CPropertyPage *pPage ); void RemovePage( int nPage ); (9)EndDialog方法 其原型为: void EndDialog( int nEndID ); 2.CPropertyPage类 该类从对话框类派生,它的对象表示单个的属性页。使用方法如同使用标准的对话框一样,进行数据交换时,也是通过变量和属性页控件进行数据交换来完成的。 该类实现了对属性页的封装,同时还提供一些非常有用的成员函数和成员变量,通过这些成员,可以很方便的操作和定制属性页的各个特性。 (1)CPropertyPage方法 其原型为: CPropertyPage( ); CPropertyPage( UINT nIDTemplate, UINT nIDCaption = 0 ); CPropertyPage( LPCTSTR lpszTemplateName, UINT nIDCaption = 0 ); (2)Construct方法 其原型为: void Construct( UINT nIDTemplate, UINT nIDCaption = 0 ); void Construct( LPCTSTR lpszTemplateName, UINT nIDCaption = 0 ); (3)OnApply方法 其原型为: virtual BOOL OnApply( ) { ASSERT_VALID(this); OnOK(); return TRUE; } (4)OnOK方法 其原型为: vir
显示全部