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.

INTERFACES AND MEMBERS<br />

error message “Run-time error ‘13’ ; Type mismatch”.<br />

Dim pGxApp As IGxApplication<br />

Set pGxApp = Application<br />

Dim pGxV As IGxView<br />

Set pGxV = pGxApp.TreeView<br />

'Optional interface for GxViews<br />

Dim pGxVP As IGxViewPrint<br />

'Attempting to QI to this will result in a runtime error<br />

Set pGxVP = pGxV<br />

Interfaces implemented in select instances<br />

esriGeoDatabase.-<br />

IRasterDataset<br />

esriGeoDatabase.-<br />

IRasterDataset2<br />

esriGeoDatabase.-<br />

IRasterDatasetEdit<br />

IRasterBand-<br />

Collection<br />

IRasterPyramid<br />

ISaveAs<br />

(Instance-File)<br />

ITemporaryDataset<br />

(Instance-File)<br />

IWorldFileExport<br />

(Instance-DB)<br />

IRasterPyramid2<br />

RasterDataset<br />

The RasterDataset class and the interfaces it<br />

implements when instantiated by file-based and<br />

ArcSDE software-based data<br />

Some classes have been designed to have varying implementations instead of<br />

having multiple classes that inherit from a single base or abstract class. In these<br />

cases, certain interfaces are implemented in select instances. For example, the<br />

RasterDataset class can be instantiated by different Workspace classes depending on<br />

the type of data being accessed. When file-based data is used to instantiate a<br />

RasterDataset class, the ITemporaryDataset interface is implemented; however, if<br />

ArcSDE software-based data is used to instantiate the RasterDataset class, the<br />

IRasterPyramid2 interface isn’t implemented.<br />

Interfaces that are implemented in select instances are designated with the prefix<br />

(Instance). Attempts to access a selected instance interface that hasn’t been<br />

implemented will produce a “Run-time error ‘13’ ; Type mismatch”.<br />

Dim pWsFact As IWorkspaceFactory<br />

Dim pWs As IRasterWorkspace<br />

Dim pRasterDataset As IRasterDataset<br />

'Open the workspace<br />

Set pWsFact = New RasterWorkspaceFactory<br />

Set pWs = pWsFact.OpenFromFile("D:\data\canada", 0)<br />

'Open the raster dataset<br />

Set pRasterDataset = pWs.OpenRasterDataset("Dem")<br />

'Test if interface is implemented before QI<br />

Dim pTempDS As ITemporaryDataset<br />

If TypeOf pRasterDataset Is ITemporaryDataset Then<br />

Set pTempDS = pRasterDataset<br />

End If<br />

OUTBOUND INTERFACES<br />

Outbound interfaces, also known as event interfaces, provide notification when a<br />

certain event occurs. Interaction with the members of an outbound interface<br />

requires that another object exists to catch the event occurrences; this is commonly<br />

referred to as an event sink. Event sinks have code that responds when<br />

certain events occur, an editing operation, for example. In Visual Basic, the<br />

creation of classes that will act as sinks to an outbound interface requires that the<br />

outbound interface declaration include the name of the class that implements the<br />

interface.<br />

Private WithEvents EditEvents as Editor<br />

Although the object variable has been declared with the class that will be raising<br />

the events, it points to nothing. The object variable must be initialized using the<br />

Appendix A • Reading the object model diagrams • 447

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

Saved successfully!

Ooh no, something went wrong!