Templates

A nice feature within Visual Basic that was introduced in version 5 is the concept of code and form templates. Now when you add a new form to a project, you no longer get a simple choice between a standard form or an MDI child—you are presented with a whole list of different forms. These are not "common code" in the sense of what we have discussed so far in this chapter, but are close enough to be related.

When you select one of these new types of form, a copy of a prebuilt form is taken and added to your project. In some cases this may simply mean that a few controls have already been placed on the form for you, whereas in other cases there may be significant amounts of code already added. These projects, forms, classes, and modules are all installed in the TEMPLATE folder of your Visual Basic installation.

To create your own templates, simply create the form, module, class, or project that you wish to use as a template, and then save the files in the appropriate subfolder of the TEMPLATE folder. Note that when creating a project template, if you do not want the forms, modules, or classes to be individually selectable, you should save them all in the PROJECTS folder.

What to Do When the Base Code Cannot Be Changed

The base code runs as part of an ActiveX DLL with all the functions in a GlobalMultiUse class. Subroutine Foo is part of the base code. It currently takes one parameter and is called from six applications that use the base code.

One of the six applications needs an extra parameter to be added to Foo. Due to the impact on other applications, this change to the base code is refused. So what can the application do? Simple—subclass Foo! This allows us to retain the existing functionality in the base code but to extend it specifically for this application.

It is possible to subclass our own routines in exactly the same way I described earlier the subclassing of the standard Visual Basic routines.



Ltd Mandelbrot Set International Advanced Microsoft Visual Basics 6. 0
Advanced Microsoft Visual Basic (Mps)
ISBN: 1572318937
EAN: 2147483647
Year: 1997
Pages: 168

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net