![]() | |
|
|
|
To access the contents, click the chapter and section titles.
Advanced Visual Basic Techniques
If the initialization file entry is correctly created but the server DLL is not, the Add-In Manager will be unable to install the add-in. When a developer opens the Add-In Manager, it will present an error message similar to the following: Visual Basic cannot load PropertySetter.PropSet because it is not in the system registry. Please ensure that all Add-Ins have been installed correctly.
This warning usually means there is a mismatch between the projects registered name and the project name specified in the initialization file. For example, suppose an add-in designer creates a DLL for a project with the name PropSetter. At that point, Visual Basic would create system registry entries that describe the PropSetter server. Now suppose the applications Main subroutine creates the following initialization entry: [Add-Ins32] PropertySetter.PropSet=0 When the Add-In Manager starts, it learns from the initialization file that there is an add-in with ConnectAddIn subroutine contained in the class PropertySetter.PropSet. It then checks the system registry to obtain a server for that class. Because the project name was PropSetter when the DLL was created, the Add-In Manager will be unable to find an entry for PropertySetter.PropSet. Summarizing Add-In CreationCreating an add-in server is a complicated process. Each step is simple, but there are so many steps that it is easy to miss one. The following list summarizes the steps required to create an add-in in Visual Basic 4 and Visual Basic 5:
To install the add-in using Visual Basic 4, run the application. To install the add-in using Visual Basic 5, run the subroutine that adds the server entries to VBADDIN.INI. Testing Add-InsBecause add-ins are invoked by the Visual Basic development environment, testing them is a bit unusual. The add-in designer should load the add-in project into the Visual Basic programming environment and set breakpoints in the add-ins subroutines. The project should then be executed. In Visual Basic 4, the program executes the Main subroutine, but that routine does nothing visible. In both Visual Basic 4 and Visual Basic 5, the application appears as if it is not doing anything. It is actually waiting for clients to request service. Next the developer should start a second instance of the Visual Basic programming environment. Temporarily minimizing the first instance can help make the screen appear less cluttered and confusing. In the second environment, the designer should select the Add-In Manager command from the Add-Ins menu. The Add-In Manager displays a dialog similar to the one shown in Figure 4.10. If the new add-in is not listed, something is wrong. The add-in may not be correctly installed in the initialization file VB.INI or VBADDIN.INI. One way this can occur is if the add-in was accidentally installed it in the Add - Ins 32 section instead of the Add-Ins32 section. A close look at the initialization file should verify that the add-in is installed correctly there. The add-in also might not be installed correctly in the system registry. This will happen if the projects name is not the same as the one shown in the initialization file. If the projects name is changed, the add-ins DLL must be rebuilt to update the registry. If the add-in is listed in the Add-In Manager, the designer can check the box next to it and click the OK button. At this point, the Add-In Manager will execute the add-ins ConnectAddIn subroutine. Using the first programming environment, the designer can step through the ConnectAddIn code. In the second programming environment, if the designer now opens the Add-Ins menu, any new menu items created by the ConnectAddIn subroutine should appear. By selecting one of the new menu items, the designer can activate the corresponding event handlers AfterClick subroutine. The designer can use the first programming environment to step through the execution.
When the add-in is thoroughly tested, the designer should open the Add-In Manager in the second development environment, uncheck the box next to the add-in, and click the OK button. At this point, the Add-In Manager invokes the add-in servers DisconnectAddIn subroutine. Again, the designer can step through the code using the first programming environment to verify that it works. The designer should open the second programming environments Add-Ins menu one last time to verify that the DisconnectAddIn subroutine successfully removed the add-ins menu entries. Now the designer can stop the add-in server running in the first environment. The server must not stop until the client programming environment has removed the server from its Add-Ins menu. Otherwise, the server will not be running when the Add-In Manager needs to invoke the DisconnectAddIn subroutine. If the Add-In Manager cannot run DisconnectAddIn, the menu items created by the add-in will remain in the clients Add-Ins menu until the client exits from Visual Basic. SummaryThis chapter covers the essentials of add-in creation. It explains how to build the methods necessary to implement an add-in and how to install an add-in for use in the development environment. PropertySetter shows how an add-in can modify the properties of the controls contained within a project. Using a similar technique, Chapter 5 adjusts the Left and Top properties of a group of controls to align them in rows and columns. Chapters 6 and 7 use more advanced add-in techniques to add new controls and new source code to a project.
|
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
|