18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

VISUAL C++<br />

There are many enhancements to ATL in VC7.<br />

Some of the relevant changes are covered in the<br />

section ‘ATL in Visual C++ .NET’ later in this<br />

chapter.<br />

Developing in Visual C++ is a large and complex subject, as it provides a much<br />

lower level of interaction with the underlying Windows APIs and COM APIs<br />

when compared to other development environments.<br />

While this can be a hindrance for rapid application development, it is the most<br />

flexible approach. A number of design patterns, such as COM aggregation and<br />

singletons, that are possible in Visual C++ are not possible in Visual Basic 6. By<br />

using standard class libraries, such as ATL, the complex COM plumbing code can<br />

be hidden. However, it is still important to have a thorough understanding of the<br />

underlying ATL COM implementation.<br />

The documentation in this section is based on Microsoft Visual C++ version 6<br />

and provides some guidance for <strong>ArcGIS</strong> development in this environment. With<br />

the release of Visual Studio C++ .NET (also referred to as VC7), many new<br />

enhancements are available to the C++ developer. While VC7 can work with the<br />

managed .NET environment and it is possible to work with the <strong>ArcGIS</strong> .NET<br />

API, this will only add overhead to access the underlying <strong>ArcGIS</strong> COM objects.<br />

So for the purposes of <strong>ArcGIS</strong> development in VC7, it is recommended to work<br />

the “traditional” way—that is, directly with the <strong>ArcGIS</strong> COM interfaces and<br />

objects.<br />

With the addition of the Visual C# .NET language, it is worth considering<br />

porting Visual C++ code to this environment and using the <strong>ArcGIS</strong> .NET API.<br />

The syntax of C# is not unlike C++, but the resulting code is generally simpler<br />

and more consistent.<br />

This section is intended to serve two main purposes:<br />

• To familiarize you with general Visual C++ coding style and debugging, beginning<br />

with a discussion on ATL<br />

• To detail specific usage requirements and recommendations for working with<br />

the ArcObjects programming platform in Visual C++<br />

WORKING WITH ATL<br />

This section cannot cover all the topics that a developer working with ATL<br />

should know to be effective, but it will serve as an introduction to ATL. ATL<br />

helps you implement COM objects and saves typing, but it does not excuse you<br />

from knowing C++ and how to develop COM objects.<br />

ATL is the recommended framework for implementing COM objects. The ATL<br />

code can be combined with Microsoft Foundation Class Library (MFC) code,<br />

which provides more support for writing applications. An alternative to MFC is<br />

the Windows Template Library (WTL), which is based on the ATL template<br />

methodology and provides many wrappers for window classes and other application<br />

support for ATL. WTL is available for download from Microsoft; at the time<br />

of writing, version 7.1 is the latest and can be used with Visual C++ version 6<br />

and Visual C++ .NET.<br />

ATL in brief<br />

ATL is a set of C++ template classes designed to be small, fast, and extensible,<br />

based loosely on the Standard Template Library (STL). STL provides generic<br />

template classes for C++ objects, such as vectors, stacks, and queues. ATL also<br />

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

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

Saved successfully!

Ooh no, something went wrong!