Command with Modal Dialog


This sample illustrates how you can create a command with a modal dialog. The dialog has a Rich Text Control with descriptions of the doucment, the dataframes it contains, and the layers in each dataframe.

It also has a 'Copy to Clipboard' button using which you can copy the description of the .MXD to the clipboard. You can easily modify this command so that it creates metadata for your MXD file in the format you prefer.

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. In ArcMap, open the Customize dialog. Under the Commands tab, select the 'Map Document Description' command from the Developer Samples category, and drag it on to a toolbar. Dismiss the Customize dialog.
  4. Click on the command. The modal dialog comes up with a description of the current map document.
  5. Use the 'Copy to Clipboard' button to copy the contents of the Rich Text Control to the clipboard. Paste onto a text editor. Dismiss the dialog when done.


Requires: An open map document.

Difficulty: Intermediate

Visual C++
File Description
DescDlg.cpp Implementation file for the Map Document Description dialog.
DescDlg.h Header file for the Map Document Description 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.
DescCommand.cpp Implementation file for the Map Document Description Command.
DescCommand.h Header file for the Map Document Description Command.
DescCommand.rgs Registry script file for the Map Document Description Command.
MapDocumentDesc.dsp Project file.
MapDocumentDesc.dsw Workspace file.
MapDocumentDesc.dll Compiled DLL for project.
MapDocumentDesc.cpp Implementation of DLL Exports.
MapDocumentDesc.def Module Definition file, listing exported functions.
MapDocumentDesc.idl The IDL file for the sample.
MapDocumentDesc.rc Resource file.
MapDocumentDesc.mak Make file for Project.
MapDocumentDescps.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.
Properties.bmp Bitmap for the command.

Key CoClasses: FeatureLayer, FeatureClass
Key Interfaces: IApplication, IMxDocument, IDataset, IWorkspace, IArcInfoWorkspace, IFeatureDataset, IDataset, IPropertySet, IMaps, IMap, ILayer, IDataLayer, IName, IFeatureLayer, IFeatureClass, ITable, IGeoDataset, ISpatialReference, ISpatialReferenceInfo, IProjectedCoordinateSystem, IGeographicCoordinateSystem, IProjection, IDatum, IPrimeMeridian