Tool with Modeless Dialog


This sample illustrates how you can create a tool with a modeless dialog that stays on top when you interact with the ArcMap window.

Using the tool, you select a polygon feature. The tool's dialog graphs the field values of the features within a certain distance of the feature you selected first. The dialog has options for modifying the fields graphed, and the buffer distance.

This sample used 'AtlControls.h' from the Microsoft ATL sample 'ATLCON' in order to facilitate working with controls without MFC. This header file provides thin wrappers for windows controls, so that the user experience is almost the same as when working with MFC controls.

How to use:

    Get AtlControls.h:

  1. Goto <http:\\>.
  2. Type "atlcontrols" into the search box.
  3. Find the hit ATLControls_h.htm
  4. Copy the code from the page, paste it in a new file and save it as AtlControls.h in this sample's directory.

    Compile the sample and use it:

  1. Open this sample's workspace and change the paths to esriCore.olb and ArcCATIDs.h in StdAfx.h so that they point to your ArcGIS installation.
  2. Build this sample's DLL. This will also register the command in the appropriate component category.
  3. Open the Customize dialog. Under the Commands tab, select the 'Graph Surrounding Features' command from the Developer Samples category, and drag it on to a toolbar. Dismiss the Customize dialog.
  4. Click on the tool and select a polygon feature. The modeless dialog comes up with a graph of field values of features within the default buffer distance of the feature you just selected.
  5. In the dialog, modify the 'Graph Field' and the 'Buffer Distance', and select another feature. Continue using the tool. Dismiss the dialog when done.


Requires: A polygon feature class added as layer.

Difficulty: Intermediate

Visual C++
File Description
IDGraphWin.cpp Implementation file for the Graph Dialog.
IDGraphWin.h Header file for the Graph Dialog.
AtlControls.h Header file that defines thin classes for controls for use with ATL. From Microsoft's ATLCON sample. Please download this file from the Microsoft web site.
GraphTool.cpp Implementation file for the Graph Surrounding Features Tool.
GraphTool.h Header file for the Graph Surrounding Features Tool.
GraphTool.rgs Registry script file for the Graph Surrounding Features Tool.
GraphSurrounding.dsp Project file.
GraphSurrounding.dsw Workspace file.
GraphSurrounding.dll Compiled DLL for project.
GraphSurrounding.cpp Implementation of DLL Exports.
GraphSurrounding.def Module Definition file, listing exported functions.
GraphSurrounding.idl The IDL file for the sample.
GraphSurrounding.rc Resource file.
GraphSurrounding.mak Make file for Project.
GraphSurroundingps.def Module definition file for proxy-stub Code. Make file for proxy-stub code.
resource.h Resource file.
StdAfx.h Header file that includes standard system include files.
StdAfx.cpp Source file that includes just the standard includes.

Key CoClasses: DataGraph
Key Interfaces: IDataGraph, IDataGraphProperties, IApplication, IMxDocument, IActiveView, IDocumentEvents, IActiveViewEvents, IEnumDataset, ITable, IDocumentDatasets, ITableFields, IField, IFieldInfo, ICursor, IQueryFilter, ITableSelection, ISelectionSet, IRow, IFeatureLayer, ISpatialFilter, IFeatureSelection, ITopologicalOperator, IDisplayTransformation, IScreenDisplay