This sample demonstrates using the Control's Command samples in conjunction with
the MapControl, the PageLayoutControl, and the Microsoft Windows Common ToolBar
Control, ImageList Control and TabStrip Control. For the sample to run the following
COM components must be registered on the system and referenced in Visual Basic. The ESRI
Sample commands are located at ArcObjects Developer Kit > Samples > Controls > Commands.
Each Command is added to a Command's Collection with the Command's Name property as its
key. The Command's Bitmap is added to the ImageList Control and a new Button is added to
the ToolBar Control, both with key values set to the Command's Name property. The Button's
image is accessed from the ImageList Control, and its Enabled, TooltipText and Description
properties are set to those of the Command's Enabled, Tooltip and Message properties.
A TabStrip Control has two tabs, one for the MapControl and one for the PageLayoutControl.
Each tab has a Frame associated with it containing either the MapControl or the PageLayoutControl.
When a tab is selected its associated tab is made visible and each Command in the Command's
collection is passed either the MapControl or PageLayoutControl as a hook using ICommand::OnCreate
When a user clicks a button on the ToolBar, its ButtonClick event is fired. The Command
item is returned from the Commands Collection using the Button's key value and its
OnClick event is triggered. If the Command is a type of ITool it is set to either the
MapControl or PageLayoutControl's CurrentTool.
The appearance of the ToolBar Control and the MapControl or PageLayoutControl's CurrentTool
is updated whenever the ToolBar's ButtonClick event is triggered, a tab of the TabStrip Control
is selected or the MapControl or PageLayoutControl's OnAfterDrawScreen event is triggered.
The Enabled property of each Button in the ToolBar Control is set to that of its associated
Command in the Command's Collection. If the MapControl or PageLayoutControl's CurrentTool
has become disabled its CurrentTool is set to Nothing.
How to use:
Ensure that the COM components are registered on the system.
Either run the CommandsAndTools.exe or open the CommandsAndTools.vbp and run from within the project.