Property Pages |
|
Introduction |
A property page is a dialog box, that can be positioned in front of, or behind of, another. This has the advantage of providing various dialog boxes that are “physically” grouped as one entity. Each part is represented by a tab. The tabs are usually positioned in the top section and each is used to identify a particular page:
|
To use a property page, the user clicks one. The page clicked becomes positioned in front of the other(s). The user can click another tab to select a different page:
|
Property Sheets |
To implement its functionality, the property pages are put together and kept as an entity by an object called a property
sheet that acts as their parent. Like other controls, we will see that the property pages must be added to a property sheet. BOOL CMyApp::InitInstance() { CPropertySheet MySheet; MySheet.DoModal(); } To specify your property pages as belonging to the property page, declare a variable for each one of them. Then, call the CPropertySheet::AddPage() method to add each property page. The syntax of this method is: void AddPage(CPropertyPage *pPage); This method takes the variable of each page and adds it as part of the property sheet. Here is an example: BOOL CmyApp::InitInstance() { CPropertySheet MySheet; CFirstPage First; CSecondPage Second; MySheet.AddPage(&First); MySheet.AddPage(&Second); MySheet.DoModal(); } If you want to have better access to the property sheet as a class, you should derive your own class from CPropertySheet. You will have the ability to use any or a combination of these constructors: CPropertySheet(); CPropertySheet(UINT nIDCaption, CWnd *pParentWnd=NULL, UINT iSelectPage=0); CPropertySheet(LPCTSTR pszCaption, CWnd *pParentWnd=NULL, UINT iSelectPage=0); The default constructor is used in the same circumstance as the CPropertySheet variable declared above. It allows you to create a CPropertySheet instance and change its characteristics later. Both the second and the third constructors allow you to specify a caption for the property. If you want to use the first, create a string with an identifier in a String Table and use that ID as the argument. Otherwise, when declaring a variable using the second constructor, you can directly provide a null-terminated string as argument. If you want to specify a title for the property sheet, you can call the CPropertySheet::SetTitle() method. Its syntax is: void SetTitle(LPCTSTR lpszText, UINT nStyle = 0); The first argument is a null terminated string that will be the new title. If you want the caption to display the string starting with “Properties for”, pass a second argument as PSH_PROPTITLE.
|
Practical Learning: Creating Property Sheets |
|
Related Articles:
Button |
|
Copyright © 2003-2012 FunctionX |
|