Article ID: 177629
Article Last Modified on 7/13/2004
Option Explicit
Private CurrentColor As OLE_COLOR
Public Property Get ControlColor() As OLE_COLOR
'Retrieve the current value of ControlColor
ControlColor = CurrentColor
End Property
Public Property Let ControlColor(ByVal NewColor As OLE_COLOR)
CurrentColor = NewColor
UserControl.BackColor = NewColor
PropertyChanged "ControlColor"
End Property
Private Sub UserControl_InitProperties()
'The InitProperties in this example is optional, however the
'ReadProperties and WriteProperties are required.
'
'Set the default ControlColor value to gray.
Me.ControlColor = &H8000000F
PropertyChanged "ControlColor"
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
'Without ReadProperties & WriteProperties the ControlColor
'property would only work in the design environment.
'The following line of code reads the BackColor property from the
'PropertyBag. If there is no value for the BackColor property in
'the PropertyBag, the default is set to &H8000000F (gray).
Me.ControlColor = PropBag.ReadProperty("BackColor", &H8000000F)
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
'The following line of code saves the BackColor property to the
'PropertyBag if the ControlColor property is not set, then set to
'the default, gray.
Call PropBag.WriteProperty("BackColor", Me.ControlColor,
&H8000000F)
End Sub
Keywords: kbhowto KB177629