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 />

ipActiveView->get_FocusMap(&ipFocusMap);<br />

IActiveViewPtr ipMapActiveView(ipFocusMap);<br />

ipMapActiveView->get_Extent(&g_ipCurrentExtent);<br />

// Load the same pre-authored map document into the MapControl<br />

…<br />

}<br />

6. The PageLayoutControlEvents do not indicate when the extent of the map<br />

within the data frame changes. To receive that information you will use the<br />

ITransformEvents interface of the PageLayoutControl’s focus map. Implementing<br />

a class, TransformEvents, that extends ITransformEvents accomplishes this. It<br />

will need to update the extent envelope and refresh the MapControl in<br />

VisibleExtentUpdated. To do so, your new class will need access to the<br />

g_ipMapControl and g_ipCurrentExtent global variables. Create a new file,<br />

TransformEvents.h, with the following code:<br />

#ifndef __TRANSFORMEVENTS_H_<br />

#define __TRANSFORMEVENTS_H_<br />

// ArcObjects Headers<br />

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

#include <br />

// Controls<br />

#include <br />

extern IMapControl3Ptr g_ipMapControl;<br />

extern IEnvelopePtr g_ipCurrentExtent;<br />

class TransformEvents : public ITransformEvents<br />

{<br />

public:<br />

// IUnknown<br />

IUNKNOWN_METHOD_DEFS<br />

// ITransformEvents<br />

HRESULT BoundsUpdated(IDisplayTransformation* sender);<br />

HRESULT DeviceFrameUpdated(IDisplayTransformation* sender,<br />

VARIANT_BOOL sizeChanged);<br />

HRESULT ResolutionUpdated(IDisplayTransformation* sender);<br />

HRESULT RotationUpdated(IDisplayTransformation* sender);<br />

HRESULT UnitsUpdated(IDisplayTransformation* sender);<br />

HRESULT VisibleBoundsUpdated(IDisplayTransformation* sender,<br />

VARIANT_BOOL sizeChanged);<br />

};<br />

#endif // __TRANSFORMEVENTS_H_<br />

7. Implement that class by placing the following code in TransformEvents.cpp,<br />

another new file. In particular, pay attention to VisibleBoundsUpdated. This<br />

event is triggered whenever the extent of the map is changed and is used to<br />

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

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

Saved successfully!

Ooh no, something went wrong!