You can also .develop custom ActiveX controls that enhance existing controls. There’s not a single user who wouldn’t like to add “new” features to existing controls. Many programmers add new features to standard ActiveX controls with the appropriate code from within their applications. A shortcoming of the Combo List control for
instance, is that any new entries added to its Edit box are not appended to the list of . options. In other words, the Combo Box control lets you specify a new entry but this entry isn’t automatically added to the control’s list of options. Many progammers capture the Enter keystroke in the Combo Box control and append.new entries to the control’s list manually.
I’m sure each of you would like to add your own. little feature to the standard VB controls. In this section you’ll learn how to enhance existing ActiveX controls and package them as custom controls. Obviously, you can’t change the basic functions of an existing control as you don’t have access to their code. But there’s a lot you can do by adding some code and packaging the existing control along with your code as a new: control
In this section, I’m going to enhance the Text Box control. The C Text Box custom control is a regular Text Box control that changes its default behavior depending OR whether it accepts an optional or a required field.
In this chapter’s’ folder on the CD you will also find the CL Design project which demonstrates how to add run time characteristics to a control at design time. Did you ever try to set the value’of a Scroll bar control at design time by scrolling its button? Most of us have tried this at one time or another and the. result was to move the entire control on the Form. The Scroll Bar control’s value can’t be set visually at design time. An interesting enhancement to the Scroll Bar control would’ be to provide a mechanism that would allow the developer to specify whether the control should be moved or operate as it would at run time even though it’s in design mode. The CL Design project is straightforward and I will not discuss it in this chapter. All the information you need to make a control exhibit run time behavior at design time is the Edit At Design Time property of the User Control object. If you set this property to True the Edit command will be appended to its shortcut menu. Right-click the control on the test Form and select Edit; the control will behave as if it were in run time mode. If it contains a Scroll bar control for example, you can adjust the control’s value with the mouse. The CL Design control, shown on a Form in Figure 16.17 lets the developer select the initial color at design time by sliding the three scroll bars:
The CL Design project .
exhibits run time behavior
at design time.