Partilhar via


Visual Basic Concepts

Using Standard Property Pages

Visual Basic provides three standard property pages: StandardFont, StandardColor, and StandardPicture. If you declare properties of type Font, OLE_COLOR, or Picture, Visual Basic’s Properties window will automatically associate these properties with the appropriate standard property page.

Visual Basic will not automatically add these pages to the Property Pages dialog box, however. Use the procedure shown in "Connecting a Property Page to an ActiveX Control" to add standard property pages to the list of pages that will be displayed in the Property Pages dialog box.

Note   The format used to display standard property pages in the Property Pages dialog box differs from the format used by the Properties window. For example, the Color page is in an entirely different format, and the Font page does not display all Font object properties.

Tip   If you use the Property Page Wizard to create property pages for a control with properties declared Font, OLE_COLOR, or Picture, the wizard will automatically add the appropriate standard property pages to the list of pages to be displayed.

Standard Property Pages and Multiple Properties

If your control has more than one property that uses a standard property page, and you add the page to your control’s PropertyPages property, the standard page will include a list of properties the user can select from.

For example, Figure 10.4 shows the Properties window and Property Pages dialog box for the hypothetical VirtualVelociraptor control, which has several properties of type OLE_COLOR:

Figure 10.4   The Properties window for a control with multiple color properties

As Figure 10.5 shows, the Color page displayed by the Property Pages dialog box for the VirtualVelociraptor control has a list box containing the four color properties of the control.

Figure 10.5   A standard property page showing multiple properties

Figure 10.5 also shows that the Property Pages dialog box uses a very different format than that used by the Properties window.

Note   When a standard property page displays multiple properties, the ApplyChanges event is raised each time the user selects a different property from the list.

The following code fragment shows how the StripeColor property of the hypothetical VirtualVelociraptor control should be declared in order to work with the Properties window and Property Pages dialog box:

Private mStripeColor As OLE_COLOR

Public Property Get StripeColor() As OLE_COLOR
   StripeColor = mStripeColor
End Property

Public Property Let StripeColor( _
      ByVal NewColor As OLE_COLOR)
   mStripeColor = NewColor
End Property

For More Information   See "Adding Properties to Controls" in "Building ActiveX Controls."