18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

BUILDING APPLICATIONS WITH C++ AND CONTROL WIDGETS<br />

The code shown in gray has already been<br />

entered in previous steps. It is given here to<br />

illustrate the accurate placement of the code you<br />

are adding in this step.<br />

For GTK you will need to replace the Motif<br />

headers with a single include of gtk/gtk.h.<br />

#endif<br />

// __ENGINE_CONTROL_MOTIF_EXAMPLE__<br />

2. Include the necessary files for the Motif toolkit. Make sure that String, Cursor,<br />

Object, and ObjectClass have all been defined as ESRI types, as shown<br />

below:<br />

#define __ENGINE_CONTROL_MOTIF_EXAMPLE__<br />

// Motif Headers<br />

#define String esriXString<br />

#define Cursor esriXCursor<br />

#define Object esriXObject<br />

#define ObjectClass esriXObjectClass<br />

#include <br />

#include <br />

#include <br />

#include <br />

#undef String<br />

#undef Cursor<br />

#undef Object<br />

#undef ObjectClass<br />

#endif // __ENGINE_CONTROL_MOTIF_EXAMPLE__<br />

3. Include the <strong>Engine</strong> C++ API header file:<br />

#undef ObjectClass<br />

// ArcObjects Headers<br />

Although the names are similar, AoInitialize()<br />

and the IAoInitialize interface have different<br />

purposes. While AoInitialize() is a C++ API call<br />

that initializes libraries, the IAoInitialize<br />

interface is used to handle licensing for the<br />

application.<br />

// <strong>Engine</strong><br />

#include <br />

4. Open MapViewer.cpp, a new file, in your text editor to implement your<br />

application. Include the MapViewer.h file just created.<br />

#include "MapViewer.h"<br />

5. Begin writing the main function. First initialize the <strong>ArcGIS</strong> <strong>Engine</strong> with<br />

AoInitialize, then set up the licensing for the product using IAoInitialize ><br />

Initialize(). If a user attempts to run the application without an appropriate<br />

<strong>ArcGIS</strong> <strong>Engine</strong> runtime or license, the application will exit. Notice that the<br />

scope is set to prevent ipInit from existing when ::AoUninitialize() is called<br />

later.<br />

int main (int argc, char* argv[])<br />

{<br />

// Initialize the engine<br />

::AoInitialize(NULL);<br />

{<br />

IAoInitializePtr ipInit(CLSID_AoInitialize);<br />

esriLicenseStatus status;<br />

ipInit->Initialize(esriLicenseProductCode<strong>Engine</strong>, &status);<br />

if (status != esriLicenseCheckedOut)<br />

AoExit(0);<br />

}<br />

}<br />

Chapter 6 • <strong>Developer</strong> scenarios • 361

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!