Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitleMake a property page for an ActiveX control
DescriptionThis example shows how to make a property page for an ActiveX control in Visual Basic 6.
KeywordsActiveX control, ActiveX, property page
CategoriesControls, ActiveX Controls
 
  1. Create a new ActiveX control project. Give the control properties.
  2. Invoke the Project menu's Add Property Page command. It is set to a standard size so don't resize it.
  3. On the property page:
    1. Add controls to let the user view and modify the properties.
    2. Create Boolean variables to indicate when the user changes each value.
    3. 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.
    4. When the user changes a property value, set its Boolean to True and set Changed to True.
    5. In the PropertyPage_ApplyChanges event handler, see which properties have been changed and set those values for the selected controls.
  4. Connect the property page:
    1. Open the control's form window.
    2. In the Properties window, click on the Property Pages entry. Then double click the ellipsis (...) to the right.
    3. Check the box next to your property page and click Ok.
Now the developer can click on the ellipsis next to the Custom property for your control to see the property pages.
 
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
End Sub

' Flag this value as changed.
Private Sub txtCaption_Change()
    m_CaptionChanged = True
    Changed = True
End Sub

' 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
        Next ctl
    End If
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated