Microsoft declares the Visual Basic Control Creation Edition to be one of the most significant Internet/intranet products. VBCCE (as it is affectionately called) makes the creation of an ActiveX control easy, especially for Webmasters and content creators. The VBCCE is positioned as a Visual Rapid Application Development tool for creating ActiveX controls. One can always use Visual C++ to create a complex control. To develop a reusable business function ActiveX object that can be embedded into a Web page by assembling a few available ActiveX controls, VBCCE is the preferred choice.
VBCCE is available for downloading from the URL http://www.microsoft.com/vbasic/.
Microsoft will include VBCCE as a part of the Visual Basic 5.0
family of products.
VBCCE Functionality in a Nutshell |
The focus of VBCCE is on reusability and development speed. The VB IDE with the forms package, intelligent, color-coded syntax, type-ahead editor with syntax reference and object model reference (Microsoft calls this intellisense technology), and object browser is the best in the market. The debugging facilities offered by the IDE are excellent. For starters, you can create new controls from scratch or customize existing ActiveX controls to fit an application or business problem. However, most of the developers will combine a set of existing ActiveX controls to develop a new ActiveX control module that implements a business function. You need not be an expert programmer to assemble a set of ActiveX controls to develop a single function using the VBCCE. |
In this chapter, you cover the basics of the VBCCE. In-depth coverage
requires a full book. This chapter should give you the courage,
and possibly the motivation, to delve into the realms of control
creation. While downloading the VBCCE from the Web, download the
documentation also. The files are ccedoc01.exe, ccedoc02.exe,
ccedoc03.exe, ccedoc04.exe, ccedoc05.exe, ccedoc06.exe, and ccehelp.exe.
Where and What to Look for in the VB Help Files |
The VBCCE help files and manuals contain exhaustive information varying from explaining variables and constants to descriptions on polymorphism, interfaces, type libraries, and GUIDs. You will find detailed information in the following chapters. |
The VBCCE is a typical Internet product-it is free, it can be downloaded from the URL, and it is a full product. One limitation is that it can be used to create only ActiveX components and not a full application.
To run the VBCCE, you need a computer with the following configuration:
The controls created using the VBCCE are complete ActiveX controls
that can be used in any ActiveX-supported environments including
the Microsoft Internet Explorer, Netscape Navigator (using the
ActiveX plug-in from Ncompass Labs), MS office 97 components (Word,
Excel, Access), and Lotus Notes.
Visual Basic Virtual Machine |
The VBCCE does not create a fully compiled code. It actually produces a pCode. This means that to run the controls on a client machine, you need the Visual Basic Virtual Machine. If a Web client does not have the VBVM in the system, it will be downloaded. This is a one-time event. But it does take time, and every client has to download the VBVM files. Also, whenever newer versions become available, clients should download them. If you are Web mastering an intranet, you should local host the VBVM and the base control DLLs. This allows Web clients to download the infrastructure files quicker over your faster network rather than from the Internet over proxy servers. The VBCCE comes with an Application Setup Wizard. When you create the deployment version, you have the choice of pointing to your internal server as the source for the VBVM and other required files. The required run time CAB files are listed in Table 7.1. |
File Name | Description |
MSVBVMB5.CAB | Expands to MSVBVM50.DLL-the Visual Basic Virtual Machine required to run the controls created by the VBCCE. |
CMCTLB32.CAB | Expands to COMMTB32.DLL-the common controls such as Tab, Toolbar, ProgressBar, StatusBar, TreeView, ListView, Slider, and ImageList. |
CMDLGB32.CAB | The Common Dialog controls. |
There are three ways to build an ActiveX control:
Creating a new control
Customizing an existing ActiveX control
Assembling a composite control by combining a set of ActiveX controls
This is the least common method of creating an ActiveX control. If possible, you should leave this task to the commercial control developers due to the time and effort required to create a brand new control. There will usually be a control commercially available or a shareware control that does at least part of what you want to do.
On the other hand, if you have a situation where you need to create a brand new control, do not hesitate to create one. You will need to take care of handling painting and displaying your control (called user-drawn control), managing the various states, events, and so on.
In this case, usually, the painting of the control, its states, and so on, will be handled by the control itself. Your job will first be to set default values for properties, methods, and events. Secondly, you need to come up with a design to expose some of these properties, events, and methods to the control user. You may add some interfaces as well to suit your business needs. This method is called sub-classing existing ActiveX controls.
In this case, you will be aggregating multiple controls, possibly some user input controls, some display controls, and add program logic specific to a particular business process or function. The result is a single control "assembly" with its own interfaces, properties, and methods defined by you.
To cite an example, you can build an expense report control with an aggregation of calendar control for data entry, currency control for dollar entry, and memo control for description entry. Of course, you will add a couple of image controls for your corporate logo and possibly a help control to add some online help. Once this expense report control is developed, many departments can use it to develop their own Web pages for expense reporting. If you add some properties and methods for routing the expense record, depending on the amount and so on, you have a full-fledged ActiveX control "assembly."
The VBCCE environment is an integrated editor, property inspector, project explorer, object browser, debugger, and wizard for tasks.
When you start the VBCCE program, you will be greeted with a screen like the one shown in Figure 7.1. You can either start a new control project or open an existing project. The existing and recent tabs add a nice touch to the interface.
Once you open or create a new project, you will see the VBCCE IDE as displayed in Figure 7.2. As you can see, the IDE is an MDI (Multiple Document Interface).
The various elements of the IDE are as follows:
Element | Description |
ToolBox | Contains all the registered controls in the current session that you can use. The toolbox not only contains the built-in common controls as the list box, text box, options, and check box, but you can also add other ActiveX controls. By right-clicking the toolbox, you can customize and organize it. |
Project Explorer | The project explorer displays a hierarchical expandable tree of all the objects in your project including resources, code and class modules, user controls, and forms. This helps organization and also allows you to jump directly into any object. |
Properties Window | This window displays the properties of the currently selected object. You can change the properties in this window. Notice the alphabetical and categorized views of the properties. |
Forms Layout | This window helps you position the form in the control. |
Figure 7.3 shows the main control window with the objects in the control.
You can either view the object window or the code window. Figure 7.4 shows the code window.
The intellisense technology (on-the-fly syntax and programming assistance and reference) employed in the code editor is worth mentioning more than once. It automatically detects the programming objects as you type and displays a drop - down list of the available properties. The intellisense functionality includes word completion, a quick information tip for a procedure or method name, a pop - up list of properties and methods for any ActiveX control in the project, and a pop - up list of constants for a property.
You will find this technology very useful as you develop programs. In the beginning, it might take a little while to get used to the pop - up property/list windows, but it is worth the effort, especially when you want to develop controls rapidly.
The ActiveX object browser, as shown in Figure 7.5, is another feature helpful for developers.
You can see the objects available with their properties, events, and methods. The Object Browser window can help you find and include in your program the right object properties, methods, and events across the various object model libraries installed in your system.
VBCCE has extensive debugging facilities, including a Locals Window with a call stack browser and current variable display, a Watch window, and the Immediate Window.
The VBCCE comes with a set of task wizards to make control creation and deployment easy. The primary ones are the Setup Wizard, Property Page Wizard, and the ActiveX Control Interface Wizard.
The Setup Wizard The setup wizard makes it easy to make a deployment configuration. This wizard runs through the project file and makes a dependency INF file. It then creates the CAB files with the required files, ocxs, and so on. An important note is that the downloading of the dependent files is done only on an as-needed basis when the client invokes your control. The loader will look at the INF file and the installed components in the client system. It will then download the files that are not in the client system and run your control.
The Property Page Wizard This wizard enables you to add property pages to your control. Users will invoke this page at design time by clicking the right mouse button. This allows user customization capability to your control. The property page can also include a preview of your controls after the various properties are set. This preview gives your users valuable feedback as it designs the Web pages using your control.
The ActiveX Control Interface Wizard This wizard helps expose the methods, events, and properties to the control user. You should run this wizard after you have placed all the controls. The wizard will examine all the controls in the project and list all the properties, events, and methods. You can then select the ones you want to expose in your control. Once you have selected the list, the wizard will generate stubs for procedures and functions.
Now that you are assembling third-party controls to make your own controls, you should be aware of the licensing implications. To use a third-party control during development, you will normally get the Design Time Control. After you have created your control assembly, you will be distributing the runtime of the third-party tools you have used. Usually, the design and runtime are controlled by license files. Some companies give two versions-design time and the runtime version.
Here are some good practices and guidelines to remember when you create your own controls. The Visual Basic Manual contains more detailed information under the Appendix ActiveX Component Standards and Guidelines. Also, you should keep looking for information on good development practices, naming conventions, and so on, in the Web, as well as in books. For your controls to be reusable, first they should be easy to use.
This is a good time to iterate the steps you will go through to develop an ActiveX control. These steps are based on recommendations by Microsoft in their manuals. The following steps will help you put all you've seen in this chapter into proper perspective.