|Title||Make a property page for an ActiveX control|
|Description||This example shows how to make a property page for an ActiveX control in Visual Basic 6.|
|Keywords||ActiveX control, ActiveX, property page|
|Categories||Controls, ActiveX Controls|
Now the developer can click on the ellipsis next to the Custom property for your control to see the property pages.
- Create a new ActiveX control project. Give the control properties.
- Invoke the Project menu's Add Property Page command. It is set to a standard size so don't resize it.
- On the property page:
- Add controls to let the user view and modify the properties.
- Create Boolean variables to indicate when the user changes each value.
- In the PropertyPage_SelectionChanged event handler, set the values of the controls on the property page using the property values from the selected controls in the application. Set the property Booleans to False and set Changed to False.
- When the user changes a property value, set its Boolean to True and set Changed to True.
- In the PropertyPage_ApplyChanges event handler, see which properties have been changed and set those values for the selected controls.
- Connect the property page:
- Open the control's form window.
- In the Properties window, click on the Property Pages entry. Then double click the ellipsis (...) to the right.
- Check the box next to your property page and click Ok.
Private m_CaptionChanged As Boolean
' Display the first control's property values.
Private Sub PropertyPage_SelectionChanged()
Dim ctl As Object
' Get the first control.
Set ctl = SelectedControls.Item(0)
' Display the value.
txtCaption.Text = ctl.Caption
' The user hasn't changed anything yet.
m_CaptionChanged = False
Changed = False
' Flag this value as changed.
Private Sub txtCaption_Change()
m_CaptionChanged = True
Changed = True
' Apply any changes to the selected controls.
Private Sub PropertyPage_ApplyChanges()
Dim ctl As Object
Dim new_caption As String
If m_CaptionChanged Then
new_caption = txtCaption.Text
For Each ctl In SelectedControls
ctl.Caption = new_caption