Visual Basic Concepts
Creating an ActiveX DLL
Components provide reusable code in the form of objects. An application that uses a component’s code, by creating objects and calling their properties and methods, is referred to as a client.
Components can run either in-process or out-of-process with respect to the clients that use their objects. An in-process component, or ActiveX DLL, runs in another application’s process. The client may be the application itself, or another in-process component that the application is using.
Figure 2.1 In-process components are used by applications or other in-process components
.gif)
The series of step-by-step procedures in this chapter builds an in-process component called ThingDemo, with class modules that demonstrate object lifetime, global objects, and objects that control modal and modeless dialog boxes.
You’ll also see how to debug an ActiveX DLL in process, by running the DLL and a test project together in the Microsoft Visual Basic development environment.
The procedures for creating the ThingDemo component build on each other. The sequence in which you perform the procedures is therefore important.
Topics
These procedures will be easier to follow if you set up your development environment as described below.
Before You Begin
- On the View menu, click Toolbox to open the Toolbox.
- On the View menu, click Project Explorer to open the Project Explorer window. The Project Explorer window will be used extensively to switch between project files.
- If the Project Explorer window is in Folder view, as shown below, click the Toggle Folders button on the Project Explorer window toolbar to turn the folders off.
.gif)
- On the View menu, click Properties Window to open the Properties window.
- On the Tools menu, click Options to open the Options dialog box.
Select the Editor tab, and make sure Require Variable Declaration is checked. This makes it much easier to catch typing errors.
Select the Environment tab. Make sure Prompt To Save Changes is checked, then click OK. This will make it easy to save changes to the project as you go along.