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.

VISUAL C++<br />

Creating an MFC dialog box-based application<br />

If you do not have a dialog box in your application or component, here are the<br />

steps to create an MFC dialog box application.<br />

1. Launch Visual Studio C++ 6 and click New.<br />

2. Click the Projects tab and choose MFC AppWizard (exe). Enter the project<br />

name and location and click OK.<br />

3. For Step 1 of the wizard: From the radio buttons, change the application type<br />

to Dialog Based. Click Next.<br />

4. For Step 2 of the wizard: The default project features are fine, although you<br />

can uncheck AboutBox to simplify the application. Ensure that the option to<br />

support ActiveX controls is checked. Click Next.<br />

5. For Step 3 of the wizard: The default settings on this page are fine. The MFC<br />

DLL is shared. Click Next.<br />

6. For Step 4 of the wizard: This shows you what the wizard will generate. Click<br />

Finish.<br />

You should now have a simple dialog box-based application. In the resource view,<br />

you will see “TODO: Place Dialog Controls Here”. You can place buttons, list<br />

boxes, and so forth, in this dialog box, and the dialog box can also host ActiveX<br />

controls; there are two approaches to doing this, as discussed below. You can also<br />

compile and run this application.<br />

Inserting ActiveX controls on a dialog box in<br />

Visual Studio C++ Design time. The<br />

TOCControl and MapControl have been<br />

added to the dialog box. The ToolbarControl is<br />

next.<br />

Hosting controls on an MFC dialog box and accessing them using<br />

IDispatch<br />

1. Right-click the MFC dialog box and click Insert ActiveX control.<br />

2. Double-click a control from the list box. The control appears on the dialog<br />

box with a default size.<br />

3. Size and position the control as required.<br />

4. Repeat steps 1 through 3 for each control.<br />

5. You can right-click the control and choose Properties to<br />

set the control’s design-time properties.<br />

6. To access the control in code, you will need <strong>ArcGIS</strong><br />

interface definitions for IMapControl, for example. To do<br />

this use the #import command in your stdafx.h file. See<br />

the section ‘Importing <strong>ArcGIS</strong> type libraries’ on how to<br />

do this.<br />

7. MFC provides control hosting on a dialog box; this will<br />

translate Windows messages, such as WM_SIZE, into<br />

appropriate control method calls. However, to be able to<br />

make calls on a control, there are a few steps you must<br />

perform to go from a resource ID to a controls interface.<br />

The following code illustrates setting the TOCControl’s<br />

Buddy to be the MapControl:<br />

126 • <strong>ArcGIS</strong> <strong>Engine</strong> <strong>Developer</strong> <strong>Guide</strong>

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

Saved successfully!

Ooh no, something went wrong!