The properties page allows ActiveX Control users to view and modify ActiveX control properties. You can access these properties by calling the Control Properties dialog box. This dialog box contains one or more property pages. These property pages provide a custom graphical interface for viewing and editing control properties.
The ActiveX control property page is displayed in two ways:
- When the Properties predicate (OLEIVERB_PROPERTIES.
- The container can display its own stateless dialog box, which displays the properties page of the selected control.
The "properties" dialog box (as shown in) consists of the following parts: display the area of the current property page, tabs for switching between property pages, and a set of buttons for executing regular tasks; general Tasks refer to tasks such as closing the property page dialog, canceling any changes, or immediately applying any changes to ActiveX controls.
"Properties" dialog box
This article describes topics related to the use of property pages in ActiveX controls. These topics include:
- Default property page for ActiveX control implementation
- Add controls to the properties page
- Custom DoDataExchange Functions
Implement default property page
If you use the ActiveX control Wizard to create a control project, the ActiveX control wizard provides a default property page class for controls derived from COlePropertyPage. Initially, this property page is blank, but any dialog box control or control set can be added to it. Because the "ActiveX Control wizard" creates only one property page class by default, you must use "Class View" to create other property page classes (also fromCOlePropertyPage). The process of implementing the property page (in this example, the default property page) is divided into three steps:
Implementation property page
- SetCOlePropertyPageAdd the derived class to the control project. If the project is created using the ActiveX control wizard (for example, in this example), the default property page class exists.
- Use the "dialog box Editor" to add any controls to the property page template.
- Custom slaveCOlePropertyPageThe
DoDataExchangeFunction to exchange values between the property page control and ActiveX control.
For example, the following procedure uses a simple control named "Sample. "Sample" is created using the "ActiveX Control wizard" and only contains common Caption attributes.
Add controls to the properties page
Add controls to the properties page
- When the control project is opened, open "resource view ".
- Double-click the "Dialog" directory icon.
- OpenIDD_PROPPAGE_SAMPLEDialog box.
The ActiveX Control wizard adds the project name to the end of the dialog box ID (Sample in this example ").
- Drag and Drop the selected control from the toolbox to the dialog box area.
- In this example, the text Label control "Caption:" andIDC_CAPTIONThe edit box control of the identifier is sufficient.
- On the toolbar, click Save to save the changes.
The user interface has been modified. Now you need to link the edit box and the Caption attribute. In the next section, EditCSamplePropPage::DoDataExchangeThe function completes this operation.
Custom DoDataExchange Functions
The DoDataExchange function on the property page allows you to link the property page value to the actual property value in the control. To create a link, you must map the appropriate property page fields to their respective control properties.
Use attribute pageDDP _Functions implement these mappings.DDP _TheDDX _Functions are similar, but there is one exception. Except for reference to member variables,DDP _The function also uses the name of the control property. Below is the property pageDoDataExchangeA typical item in a function.
DDP_Text(pDX, IDC_CAPTION, m_caption, _T("Caption"));
Use this functionDDP_TEXTThe function returnsm_captionMember variables are associated with Caption.
After the property page control is inserted, you must useDDP_TextFunction controls on the property pageIDC_CAPTIONEstablish a link with the actual control property Caption (as described above ).
You can also use the DDP function for other dialog box control types (such as check boxes, single-choice buttons, and list boxes. The following table lists the complete property pages.DDP _Function set and functions:
Property page Functions
| Function Name |
Functions |
| DDP_CBIndex |
The index and control attributes of the selected string in the linked combo box. |
| DDP_CBString |
Link the selected string and control attributes in the combo box. The selected string can start with a letter that is the same as the property value, but does not have to match it completely. |
| DDP_CBStringExact |
Link the selected string and control attributes in the combo box. The string values of the selected string and attribute must match exactly. |
| DDP_Check |
Link check box and control properties. |
| DDP_LBIndex |
The index and control attributes of the selected string in the link list box. |
| DDP_LBString |
The selected string and control properties in the link list box. The selected string can start with a letter that is the same as the property value, but does not have to match it completely. |
| DDP_LBStringExact |
The selected string and control properties in the link list box. The string values of the selected string and attribute must match exactly. |
| DDP_Radio |
Link radio button and control properties. |
| DDP_Text |
Link text and control properties. |