AGI STK Engine (4DX) Blog

June 3, 2009

Using the Object Model with C++Builder 2009

Filed under: Uncategorized — Tags: , , , , — Logan @ 4:19 pm

We recently had a question about how to use the STK Engine within C++Builder (previously known as Borland C++ and now produced by CodeGear). In this article I will walk you through the steps required to enable the STK Engine in your C++ Builder environment. A full example is provided and attached to this article. It is a C++Builder port of the STKProTutorial tutorial available in a regular STK 8 install.

To import the STK libraries into C++Builder 2009, follow the step-by-step instructions below:

1. On the menu bar, click Tools -> Options. Browse to the Type Library category. In the section labeled "Ignore special CoClass flags when importing," check the box labeled "Can Create".


2. On the menu bar, click Component -> Import Component. Select ActiveX Control, then click Next. Find your AGI STK X version in the list. If it is not listed, click Add and navigate to <STK Install Directory>\bin\STKX.dll. On the next page, create a palette page name for your AGI controls (I used "AGI STK 8 Controls"), and choose a "unit directory" to store the generated wrappers in. Save this directory name for later. Also, make sure that "Generate Component Wrappers" is checked; this is critical to actually creating the Map and Globe controls.


On the next screen, select "Install to new package" and choose a directory to place the components package in. Save this location also; we will need it later. Select Finish, and C++Builder will automatically generate wrappers for the STK X components and install the ActiveX controls to the tool palette under your chosen page.

3. Repeat step 2, but this time select "Import Type Library" and select the AGI STK Objects DLL (<STK>\bin\AgStkObjects.dll) . Make sure "Generate Component Wrappers" is not checked this time. Install it to the same unit directory as last time. Then select "Install to existing package" and choose the same location as you installed the STK X package.

4. Now open Tools -> Options again, and browse to the Paths and Directories category. Edit the Include Path by adding a semicolon (;) and then the path to the unit directory that you stored the wrappers in earlier.


5. Close the project and open a new GUI project. In the toolbox there should be a new category containing the map & globe ActiveX controls that were imported earlier. Drag these controls (TAgUiAxVoCntrl and TAgUiAx2DCntrl) to the GUI form and C++Builder will automatically implement some dependencies for you.

6. Then add the following lines to your project header file:

#include "STKObjects_TLB.h"

using namespace Stkxlib_tlb;
using namespace Stkobjects_tlb;

From here you are free to use the Object Model API to create and manipulate objects however you choose.

A complete STK 8 Engine example for C++Builder can be found here. It is designed to follow the procedures outline in the STK Pro Tutorial included with any STK 8 install.

Example screenshot:


No Comments »

No comments yet.

RSS feed for comments on this post.

Leave a comment

Powered by WordPress