Selecting the Property Pages VB Help

In this window you select the Property Pages for your control. This window contains some (or all) of the standard Property Pages:

• Standard Font which allows you to set the font
• Standard Picture which allows you to set Picture properties
• Standard Color which allows you to set color

For our control’s Property Pages we need the Standard Color page plus a custom one which we car add by clicking on the Add button. The Wizard prompts you to enter the name of the custom page. Enter Text Properties and then click the Next button.

Can you see why the Wizard selected the Standard Color page for US? Our custom control provides the Back Color and Fore Color properties, which are set through the Standard Color property page. If you don’t want a Property Page for the color-related properties clear the check box that precedes the property name. But we do need the . page for specifying color so leave this page checked. You can also rename the pages with the Rename.button

Assigning Properties to the Property Pages

In this window you specify the properties to be displayed in each Property Page. The Wizard has already assigned the color-related properties to the Standard Color page the Font property to the Standard Font page and the Picture property to the Standard Picture page. The custom properties however have not.been assigned to any page because wizard know where they belong. To add the Caption property to the Text Properties page follow these steps:
1. Select the Text Properties tab.
2. Select the Caption property from the list on the left and then click the single right-arrow button to add it to the Text Properties page.
3. Click Next to display the last page of the Property Page Wizard and then click Finish.

If you examine this window of the wizard carefully you’ll probably notice something strange. Not all of the custom properties appear in the Available Properties list. Instead, some other property names appear in the list. The wizard can’t handle properties of custom type. The Text Alignment and Effect properties are custom  data types (the Align and Effects enumerated types we declared in the code), so they are omitted. If you want a Property Page on which the developer can specify the appearance of the control you must-end the Text alignment and Effect properties to the Text Properties page. Unfortunately you add these properties through the wizard. you’ll have to do it manually.

But first, let’s see what the Wizard has done for us. Follow these steps:
1. Switch to the test Form and right-click on the FLEX Label control
2. From the shortcut menu, choose Properties to display the two Property Pages shown in Figures 16.10 and 16.11.

The Color Property Page of
the FLEX Label control

FIGURE 16.10:

FIGURE 16.10:

The Text Properties Property
Page of the FLEX Label
control

 

FIGURE 16.11:

FIGURE 16.11:

The Color page looks fine, but the Text Properties page needs drastic improvement  the Wizard just dumped a Label and a Extension control on it and you should not only fix their appearance but provide the actual code as well.

The Color tab has a Properties list that contains the names of the color-related properties. Had you created more color properties for the custom control they would appear on the same page. To assign a new value to a color-related property do one of the following:

• Select it and then chose a standard color from the Widows palette.
• Specify a custom color by clicking the Edit Custom Color button.

The new color appears in front of the property’s name in the Properties list. If you click the Apply button the gradient on the control is redrawn according to the new selection. The Text Properties page lets you specify the Caption property’s value by entering a value in a Text Box control. Click Apply for the property to take effect on the control. You should experiment with the other tabs of the Property Pages to see how they behave.

If you look at the Project window, you will see that the WIZard. has added another folder, the Property Pages folder. This new folder contains the Caption Properties file. Double-click it to open the page’s Form in design mode. Notice that the OK Cancel, and Apply buttons are not part of the Form. They belong to a Tab Strip control which displays the Property Pages at run time (this control isn’t available to you ,and can’t even be customized). Moreover there is no Form for the Color, Font, and Picture Property Pages. These are standard Property Pages, and they are manipulated entirely by Visual Basic. You can’t modify the Font-Property Page built by the
Wizard but you can create anew custom page for specifying colors if you really don’t like the standard.

one.Let’s examine the code created by the Wizard for the Caption properties Property Page .

The Caption properties property Page

.Private Sub txtCaption_ChangeO
Changed – True
End Sub
Private Sub PropertY Page-APply Changes()
Selected Controls(O)Caption – txtCaption.Text
End Sub
Private Sub Property Page_Selection Changed()
Caption Text – Selected Controls(0) caption
End Sub

The subroutine text Caption_Change O takes place every time the user changes the direction by typing something in the text Caption Text Box. By setpng the Changed variable to True the code enables the Apply button (which is disabled as long as the Caption property doesn’t change value). Visual Basic uses the Changed property to determine when the Apply button must be enabled.

The new setting of a property isn’t applied to the control automatically, of course. The code that actually applies the changes must be entered in the Property Pages_ Apply Changes event which is triggered every time the Apply button is clicked. From within this event, you must update the control’s property. Because the Property Page is a separate Form and can’t know the name of the selected control (there could  be multiple instances of the same control on the Form) the code uses the Selected- Controls(O) object to access the selected control and set its properties. Selected Controls is a collection that represents all the selected controls on the Form. The item of the collection with index 0 is the first selected control.

Finally the Property  Page_Selection Changed O event occurs whenever the user selects another tab on the Property Pages dialog box. This is a good place to insert initialization code. The Property Page_Selection Changed subroutine’s code assigns the current setting of the Caption property of the selected control to the Text Box control in which the user is supposed to enter the property’s value.

Posted on November 6, 2015 in Building AdiveX Controls

Share the Story

Back to Top