Home > ActiveX Controls > How to Work with ActiveX controls > Adding ActiveX components
TerraExplorer exposes four separate ActiveX components, the 3D Window,
the Information Tree, the Navigation Map, and the external 3D Window.
These components are exposed through ActiveX Control technology. You
can use the ActiveX viewers in your custom user interface from an
HTML page, JavaScript or C++ application, or any other environment
that supports adding ActiveX objects.
When you use the ActiveX component, you must use the 3D Window component.
This launches TerraExplorer with the 3D window displayed in the ActiveX
display area, and without the standard TerraExplorer GUI. You can
then also add the other ActiveX objects.
Working with Scripting languages
In order to use ActiveX using a web browser, the browser must support ActiveX controls. There are two objects, defined by the <OBJECT> tag, that insert the 3D Window, Information Tree, Navigation Map, and external 3D Window viewers to your HTML page.
VBScript is used to demonstrate the following actions. You can use the scripting language of your choice (e.g., JavaScript
1. Define
the TerraExplorer3DWindow Object – You should use the HTML Object
tag to declare the object using TerraExplorer3DWindow’s unique class
ID.
Note: The four TerraExplorer ActiveX objects have different
unique class IDs.
<OBJECT ID="TerraExplorer3DWindow" CLASSID="CLSID:3a4f9192-65a8-11d5-85c1-0001023952c1" ></OBJECT>
2. Define
the TerraExplorerInformationWindow Object – You should use the
HTML Object tag to declare the object using TerraExplorerInformationWindow’s
unique class ID.
Note: The four TerraExplorer ActiveX objects have different
unique class IDs.
<OBJECT ID="TerraExplorerInformationWindow" CLASSID="CLSID:3a4f9193-65a8-11d5-85c1-0001023952c1" ></OBJECT>
3. Define
the TerraExplorerNavigationMap Object – You should use the HTML
Object tag to declare the object using TerraExplorerNavigationMap’s
unique class ID.
The four TerraExplorer ActiveX objects have different unique class
IDs.
<OBJECT ID="TerraExplorerNavigationMap" CLASSID="CLSID:3a4f9194-65a8-11d5-85c1-0001023952c1" ></OBJECT>
4. Optional: Define External TerraExplorer3DWindow Objects – You should use the HTML Object tag to declare the object using TerraExplorer 3DWindowEx’s unique class ID.
Note: The four TerraExplorer ActiveX objects have different unique class IDs.
<OBJECT ID="TerraExplorer3DWindowEx" CLASSID="CLSID:3a4f9196-65a8-11d5-85c1-0001023952c1" ></OBJECT>
5. Set Object’s Width and Height – To control the size of the ActiveX objects use the width and height attributes.
<OBJECT ID=" TerraExplorer3DWindow" CLASSID="CLSID:3a4f9192-65a8-11d5-85c1-0001023952c1" width=500 height=400></OBJECT>
<OBJECT ID="TerraExplorerInformationWindow" CLASSID="CLSID:3a4f9193-65a8-11d5-85c1-0001023952c1" width=200 height=400 ></OBJECT>
<OBJECT ID="TerraExplorerNavigationMap" CLASSID="CLSID:3a4f9194-65a8-11d5-85c1-0001023952c1" width=300 height=300 ></OBJECT>
<OBJECT ID=" TerraExplorer3DWindowEx" CLASSID="CLSID:3a4f9196-65a8-11d5-85c1-0001023952c1" width=500 height=400></OBJECT>
6. Add
a TerraExplorer object – Use the <OBJECT> tag to define
a TerraExplorer object.
< OBJECT ID ="SGWorld61" classid="CLSID: 3a4f91b1-65a8-11d5-85c1-0001023952c1"
style="visibility:hidden;height:0 "></ OBJECT >
Working with C# environment
C# allows you to easily add ActiveX controls to your application. TerraExplorer provides four ActiveX controls for the 3D Window, Information Window, Navigation Map, and external 3D Window. Add them to your project and build your own custom GUI with embedded controls.
The instructions provided here refer to Microsoft Visual Studio 2005.
1. Add
the ActiveX components to the Toolbox – While in design view,
right click on the Toolbox, and select Choose Items. In the
dialog box select COM Components tab and select the check-boxes
next to TE3DWindow Class,TE3DWindowEx Class, TEInformationWindow
Class and TENavigationMap Class, and then Click OK. Four
icons are added to your toolbox, the 3D Window ,
Information Window
, Navigation Map
,
and 3DWindowEx
controls.
2. Add the 3D Window to the form – Click on the 3D window control icon and draw the location of the 3D window on your form.
3. Add the Information Window to the form – Click on the Information Window control icon and draw the location of the Information Window on your form.
4. Add the Navigation Map to the form – Click on the Navigation Map control icon and draw the location of the Navigation Map on your form.
5. Optional – Add external 3D Windows to the form – Click on the 3DWindowEx control icon and draw the location for an external 3D window on your form. Repeat for each external 3D Window that you want to add.
Working with C++ environment
There are several ways in which a C++ client can work with the ActiveX controls. This document describes just one way of using the TerraExplorer from within a simple ATL dialog application.
1. Derive
your dialog from the ATL template class CAxDialogImpl.
This allows your dialog to host ActiveX controls, such as the 3D Window,
the Information Window, the Navigation Map, and the external 3D Window.
Your dialog class should look something like this:
class CMyDialog :
public
CAxDialogImpl<CMyDialog>
{
public:
:
:
:
};
You can use the Visual C++ “insertàNew
ATL Object…” menu option to create your dialog. Select the “Dialog”
object from the “Miscellaneous” category.
2. Add
the 3D Window, Information Window, Navigation Map, and external 3DWindow
to your project.
Add the following members to your dialog class definition:
CAxWindow m_wnd3D;
CAxWindow m_wndInfoTree;
CAxWindow m_wndNavMap;
CAxWindow is an ATL class that can be used to encapsulate ActiveX controls.
Add the following lines to your dialog OnInitDialog handler:
LPCTSTR pszTE3DName = _T("TerraExplorerX.TE3DWindow");
RECT rect1 = { 10, 10, 350, 250 };
m_wnd3D.Create(m_hWnd, rect1, pszTE3DName, WS_CHILD | WS_VISIBLE);
LPCTSTR pszTEInformationName = _T("TerraExplorerX.TEInformationWindow");
RECT rect2 = { 400, 10, 550, 250 };
m_wndInfoTree.Create(m_hWnd, rect2, pszTEInformationName, WS_CHILD
| WS_VISIBLE);
LPCTSTR pszTENavigationName = _T("TerraExplorerX.TENavigationMap");
RECT rect3 = { 500, 10, 650, 250};
m_wndInfoTree.Create(m_hWnd, rect3,pszTENavigationName, WS_CHILD |
WS_VISIBLE);
The first three lines create the 3D window control, the next three
lines create the Information Window control and the last three lines
create the Navigation Map.
At this point, if you compile and run your project, you should see
that your dialog contains the 3D window, Information Window and Navigation
Map (You can even start working by clicking on the 3D window and pressing
Ctrl+O to open a Fly file).