Current Tool


This sample demonstrates setting the PageLayoutControl's CurrentTool property. An array of ICommand is created with the same number of objects as a control array of option buttons on the form. The ICommands are created from the 'ESRI Sample PageLayout Commands'. For the sample to run the PageLayout.dll must be registered on the system and the 'ESRI Sample PageLayout Commands' referenced in Visual Basic.

When each ICommand is created it is passed the PageLayoutControl as a hook, so it knows what object it must work with, and is then added to the ICommand array. An option button with the same index property as the index of the ICommand in the array has its Picture, Tooltip and Enabled properties set to those of the ICommand's Bitmap, Tooltip and Enabled properties.

When a user selects an option button and fires its click event the PageLayoutControl's CurrentTool is set to the ICommand in the array with the same index as that of the option button. The PageLayoutControl's OnAfterDraw event is used to update the Enabled properties of the option buttons based upon the Enabled state of the ICommands in the array when the esriViewForeground phase has been refreshed.

Note that a control array of option buttons is used to reflect the ICommands that implement ITool and are used to interact with the PageLayoutControl. A control array of command buttons is used to reflect the ICommands that do not implement ITool.

The Microsoft Common Dialog Control (Comdlg32.ocx) allows users to search and select map documents, which are validated and loaded into the PageLayoutControl using the CheckMxFile and LoadMxFile methods.

How to use:
  1. Either run the CurrrentTool.exe or open the CurrentTool.vbp and run from within the project
  2. Browse and select a Mx document to load into the PageLayoutControl.
  3. Interact with the PageLayoutControl with each of the tools.


Minimum ArcGIS Version Required: 8.2

Difficulty: Beginner

Visual Basic
File Description
CurrentTool.frm VB form file for the CurrentTool project.
CurrentTool.frx Binary file.
CurrentTool.bas VB module file for the CurrentTool project.
CurrentTool.vbp VB project file for the CurrentTool project.

Key CoClasses: PageLayoutControl
Key Interfaces: ICommand,ITool
Key Members: CheckMxFile, CurrentTool, LoadMxFile, ZoomToWholePage