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.

DEVELOPING WITH A RCOBJECTS<br />

Language<br />

Base types<br />

Extended<br />

types<br />

IDL Microsoft C++ Visual Basic Java<br />

boolean unsigned char unsupported<br />

char<br />

byte unsigned char unsupported<br />

char<br />

small char unsupported<br />

char<br />

short short Integer<br />

short<br />

long long Long<br />

int<br />

hyper __int64 unsupported<br />

long<br />

float float Single<br />

float<br />

double double Double<br />

double<br />

char unsigned char unsupported<br />

char<br />

wchar_t wchar_t Integer<br />

short<br />

enum enum Enum<br />

int<br />

Interface Pointer Interface Pointer Interface Ref.<br />

Interface Ref.<br />

VARIANT VARIANT Variant<br />

ms.com.Variant<br />

BSTR BSTR String<br />

java.lang.String<br />

VARIANT_BOOL short (-1/0) Boolean<br />

[true/false]<br />

Note the extended data types at the bottom of the table: VARIANT, BSTR, and<br />

VARIANT_BOOL. Although it is possible to pass strings using data types such as<br />

char and wchar_t, these are not supported in languages such as Visual Basic. Visual<br />

Basic uses BSTRs as its text data type. A BSTR is a length-prefixed wide character<br />

array in which the pointer to the array points to the text contained within it<br />

and not the length prefix. Visual C++ maps VARIANT_BOOL values onto 0<br />

and –1 for the False and True values, respectively. This is different from the<br />

normal mapping of 0 and 1. Hence, when writing C++ code, be sure to use the<br />

correct macros—VARIANT_FALSE and VARIANT_TRUE—not False and<br />

True.<br />

USING COMPONENT CATEGORIES<br />

Component categories are used extensively in ArcObjects so developers can<br />

extend the system without requiring any changes to the ArcObjects code that will<br />

work with the new functionality.<br />

ArcObjects uses component categories in two ways. The first requires classes to<br />

be registered in the respective component category at all times—for example,<br />

ESRI Mx Extensions. Classes, if present in that component category, have an<br />

object that implements the IExtension interface and is instantiated when the<br />

ArcMap application is started. If the class is removed from the component category,<br />

the extension will not load, even if the map document (.mxd file) is referencing<br />

that extension.<br />

The second use is when the application framework uses the component category<br />

to locate classes and display them to a user to allow some user customization to<br />

occur. Unlike the first method, the application remembers (inside its map document)<br />

the objects being used and will subsequently load them from the map<br />

document. An example of this is the commands used within ArcMap. ArcMap<br />

reads the ESRI Mx Commands category when the Customization dialog box is<br />

displayed to the user. This is the only time the category is read. Once the user<br />

selects a command and adds it to a toolbar, the map document is used to determine<br />

what commands should be instantiated. Later, when debugging in Visual<br />

Basic is covered in ‘The Visual Basic 6 development environment’ section of this<br />

chapter, you’ll see the importance of this.<br />

Chapter 4 • <strong>Developer</strong> environments • 77

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

Saved successfully!

Ooh no, something went wrong!