Building an ArcGIS Controls map viewer application


Purpose
The MapControl, PageLayoutControl, TOCControl and ToolbarControl are used in conjunction with other ArcObjects and the Control Commands to create a 'Map Viewer' application. The sample demonstrates the following:
 
  • Loading pre-authored map documents into the PageLayoutControl and MapControl using the CheckMxFile and LoadMxFile methods.
  • Setting the ToolbarControl and TOCControl 'buddy control' to be the PageLayoutControl using the SetBuddyControl method.
  • Resizing the MapControl and PageLayoutControl when the container form or dialog is resized.
  • Adding a suite of map and page navigation Control Commands to the ToolbarControl using the AddItem method.
  • Creating a popup menu from the Control Commands that works with the PageLayoutControl and displays as a right click context menu.
  • Managing the way map and layer labels are edited in the TOCControl using the LabelEdit property and the ITOCControlEvents::OnEndLabelEdit event.
  • Using the MapControl as an overview window, by using the DrawShape method to highlight the current extent of data in the PageLayoutControl.
  • Creating a custom 'Add Date' command that works with the PageLayoutControl, ToolbarControl and MapControl using the HookHelper object.
  • Customizing the ToolbarControl with the Customize property and displaying the CustomizeDialog to the end user at runtime.
 
This sample accompanies the walkthrough Building applications with C++ and control widgets.

How to use

Data has been provided for your use with this sample. It can be found at <Your ArcGIS Developer Kit Install directory>/Samples/data/GulfOfStLawrence/Gulf_of_St._Lawrence.mxd.
If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.

  1. Run the application.
  2. Use the 'Open Document' command on the ToolbarControl to browse to a pre-authored map document to load into the PageLayoutControl.
  3. Use the commands and tools on the ToolbarControl to navigate around the map document. Right click on the PageLayoutControl to display the popup menu.
  4. Use the custom 'Add Date' tool to add an element to the PageLayoutControl containing the current date.
  5. Double click on a map or layer label in the TOCControl to edit the label.
  6. Customize the ToolbarControl by adding new commands, toolsets or menus from the CustomizeDialog. To alter the appearance of an existing item on the ToolbarControl, right click on the item to display the context menu.

MapViewer.h Main header file
MapViewer.cpp Main implementation file
AddDate.h Header file
AddDate.cpp Implementation file
date.bmp AddDate custom tool icon
date.cur AddDate custom tool cursor
CustomizeDialogEvents.h Event header file
CustomizeDialogEvents.cpp Event implementation file
MapControlEvents.h Event header file
MapControlEvents.cpp Event implementation file
PageLayoutControlEvents.h Event header file
PageLayoutControlEvents.cpp Event implementation file
TOCControlEvents.h Event header file
TOCControlEvents.cpp Event implementation file
TransformEvents.h Event header file
TransformEvents.cpp Event implementation file
Makefile.SolarisMotif.Template Solaris Project Makefile to modify with the scenario
Makefile.SolarisMotif.Final Solaris Project Makefile to use for the completed scenario
Makefile.LinuxMotif.Template Linux Project Makefile to modify with the scenario
Makefile.LinuxMotif.Final Linux Project Makefile to use for the completed scenario
Download the Motif_CPP files
MapViewer.h Main header file
MapViewer.cpp Main implementation file
AddDate.h Header file
AddDate.cpp Implementation file
date.bmp AddDate custom tool icon
date.cur AddDate custom tool cursor
CustomizeDialogEvents.h Event header file
CustomizeDialogEvents.cpp Event implementation file
MapControlEvents.h Event header file
MapControlEvents.cpp Event implementation file
PageLayoutControlEvents.h Event header file
PageLayoutControlEvents.cpp Event implementation file
TOCControlEvents.h Event header file
TOCControlEvents.cpp Event implementation file
TransformEvents.h Event header file
TransformEvents.cpp Event implementation file
Makefile.SolarisGTK.Template Solaris Project Makefile to modify with the scenario
Makefile.SolarisGTK.Final Solaris Project Makefile to use for the completed scenario
Makefile.LinuxGTK.Template Linux Project Makefile to modify with the scenario
Makefile.LinuxGTK.Final Linux Project Makefile to use for the completed scenario
Download the GTK_CPP files

Download the files for all languages




Development licensing Deployment licensing
Engine Developer Kit Engine Runtime