As an illustration of the procedures involved, consider this walkthrough demonstration of building a control that wraps Objective Toolkit functionality.
After launching Visual Studio, start up a new project and select ATL Project from the Templates: frame.
Name your project acmecontrol, as shown in Figure 176.
Click OK and proceed to the next screen.
Click Finish.
Once your initial project files are generated, select Add Class from the Project menu.
Click the Stingray folder in the Categories: frame, and select Objective Toolkit Tree Control from the Templates: frame as shown in Figure 178.
Click Open to produce the following dialog:
Type the short name mytreecontrol. The wizard automatically derives class names, file names, an interface name, and so forth.
Accept these defaults by clicking Finish.
The wizard should take only a couple of seconds to generate the required source code. Examine the Class View tab which you can view by selecting View|Class View.
The wizard has generated all the required source code to instantiate and run an Objective Toolkit Tree control. Note that the one exported method, InsertItem(), is provided only as an example. As a developer, you will add method declarations (under the Imytreecontrol interface) and implementation (under Cmytreecontrol) to export and/or extend the Objective Toolkit Tree control's functionality in your own custom control.
We are almost ready to build our control, but first there are a few things we must do to make sure RTTI is enabled.
Open the Project Properties dialog by selecting Properties from the Project menu.
Select Language from the C/C++ folder as shown in Figure 181.
Make sure that Enable Run-Time Type Info is set to Yes.
You can now build your control.
Start the build process.
After successfully building your control, you are ready to test it. You have two options:
Option 1—Open an existing VB project
Open an existing VB project by clicking File|Open|Project.
Option2—Open a new project
Create a new VB project from scratch, add in the control you've just built, and proceed from there. This second option is illustrated here.
Create a new Visual Basic project by clicking File|New|Project.
Select Windows Application from the Templates: frame, as show in Figure 184.
This leads to the familiar VB default new project development environment…
Now, add your freshly-built ActiveX control to your VB form by right clicking on the Toolbox and select Customize Toolbox.
Find your ActiveX class, as shown below.
After you click OK, the icon for the control (currently the default ATL icon) appears on VB's tool palette.
Click the tree control icon (circled above) and draw an instance of the tree control on the VB form.
Add code to the Form_Load procedure:
Finally, run the VB project.
Copyright © Rogue Wave Software, Inc. All Rights Reserved.
The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.