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; 1. Start a new project. 2. Set the project options. In Visual Basic 4, use the Options... command in the Tool menu to set the Startup Form, Project Name, and Start Mode. In Visual Basic 5, use the Properties... command in the Project menu to set the Project Type and Project Name. 3. Create an add-in class that supplies the ConnectAddIn and DisconnectAddIn subroutines. 4. Create event handler classes with AfterClick subroutines. If the add-in performs a single task, the class created in step 3 can also provide the AfterClick subroutine. 5. Create Sub Main. It should register the server in the proper section of VB.INI or VBADDIN.INI. 6. Using the Object Browser, set the name that should be displayed by the Add-In Manager. 7. Create the server DLL. 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-Ins Because 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-iní's 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.
Figure 4.10: Selecting PropertySetter in the Add-In Manager. 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 project's name is not the same as the one shown in the initialization file. If the project's name is changed, the add-in's 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 press the OK button. At this point, the Add-In Manager will execute the add-in's 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 handler's 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 server's 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 environment's Add-Ins menu one last time to verify that the DisconnectAddIn subroutine successfully removed the add-in's 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 client's Add-Ins menu until the client exits from Visual Basic. Summary This 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. [Home Page] [Tutorial Page] [Main Add-In Page] [Prev Lesson]
|
Quick searches: Site Search | Advanced Site Search |
|
By using this site you agree to its terms and conditions VB Explorer and VBExplorer.com are trademarks of Exhedra Solutions, Inc. |