Creating the Server DLLOnce the appropriate entry has been added to the correct initialization file, the Add-In Manager knows what class objects it should use to connect and disconnect the server from the Add-Ins menu. Before an application can create an instance of a class defined by the server, the system registry needs to contain entries that describe the server in more detail. The registry entries also give the name that the Add-In Manager displays when the developer selects add-ins. This name may be different from the project name. The project name is used by the Add-In Manager to invoke the server's ConnectAddIn and DisconnectAddIn subroutines. If the project's name is MyProject and the class containing the ConnectAddIn subroutine is named Connector, then the Add-In Manager will invoke the subroutine MyProject.Connector.ConnectAddIn. The name placed in the registry tells the Add-In Manager what to display in its list of add-ins. Figure 4.6 shows the Add-In Manager. Here the PropertySetter add-in has the name "Property Setter."
Figure 4.6: The Add-In Manager. Dealing directly with the system registry entries needed to set the add-in's name is quite complicated. Fortunately, Visual Basic handles this detail automatically. In Visual Basic 4, when the add-in designer invokes the Make OLE DLL File... command from the File menu, Visual Basic creates the appropriate registry entries. Similarly, in Visual Basic 5, when the designer selects the Make PropSet.dll... or Make PropSet.exe... commands from the File menu, Visual Basic creates these entries. These commands are described further in a few paragraphs. When Visual Basic makes these entries, it specifies the server's registry name using a value supplied by the Visual Basic programming environment. The add-in designer can set this value by entering the name the Add-In Manager should display in the Description box, in the Member Options dialog shown in Figure 4.7.
Figure 4.7: Setting the server's name in the Member Options dialog. The way the Member Options dialog is accessed is different in Visual Basic 4 and Visual Basic 5. In either case, the add-in designer begins by opening the Object Browser by pressing F2 or by selecting the Object Browser... command from the View menu. The designer then selects the class that contains the ConnectAddIn and DisconnectAddIn subroutines. Figure 4.8 shows the Visual Basic 4 Object Browser at this point. When the designer clicks the Object Browser's Options... button, the Member Options dialog appears.
Figure 4.8: Locating the server class in the Visual Basic 4 Object Browser. When using the Visual Basic 5 Object Browser, the designer should locate the class that provides the ConnectAddIn and DisconnectAddIn subroutines and click the right mouse button over that class. This makes a context menu appear, as shown in Figure 4.9. If the designer selects the Properties... command from this menu, the Member Options dialog appears.
Figure 4.9: Locating the server class in the Visual Basic 5 Object Browser. Once the add-in's name is specified, the designer can create the OLE server. In Visual Basic 4, this is done by selecting the Make OLE DLL File... command from the File menu. In Visual Basic 5, the designer should select the Make PropSet.dll... or Make PropSet.exe... command from the File menu. After the designer enters the name of the file that should contain the results and clicks the OK button, Visual Basic creates the file. It also creates the system registry entries that identify the server and tell the Add-In Manager the server's name. 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 project's 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 application's 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. Since the project name was PropSetter when the DLL was created, the Add-In Manager will be unable to find an entry for PropertySetter.PropSet. [Home Page] [Tutorial Page] [Main Add-In Page] [Next Lesson] [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. |