Share CommandPool


PurposeThis sample demonstrates what happens when multiple ToolbarControl's share the same CommandPool and uses the ToolbarControl in conjunction with the MapControl and Control Commands.

How to use

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. Browse to a map document to load into the MapControl.
  3. Select a ZoomIn, ZoomOut or Pan tool. Notice that only one tool is depressed.
  4. Share the same CommandPool between both ToolbarControls. Notice that the UsageCount changes.
  5. Select a ZoomIn, ZoomOut or Pan tool. Notice that the same tool on both ToolbarControls becomes depressed.

Additional information

The AddItem method is used within the Form_Load event to add 4 new item's to both ToolbarControl1 and ToolbarControl2. Three of the items that are added to ToolbarControl1, are also add to ToolbarControl2. By default each ToolbarControl has its own CommandPool to which these item's commands are added. One instance of each command in the CommandPool of ToolbarControl1 is used by ToolbarControl1, so the ICommandPool::UsgaeCount of each command is 1. This is the same for ToolbarControl2.
            
By clicking the check box both ToolbarControl1 and ToolbarControl2 share the CommandPool of ToolbarControl1. If any command used by ToolbarControl2 is already in the CommandPool, the ICommand::UsageCount of that command increments by 1. If any command used by ToolbarControl2 is not in the CommandPool, the command is added to the CommandPool with an ICommandPool::UsgaeCount of 1.

ShareCommandPool.h Main header file
ShareCommandPool.cpp Main implementation file
Makefile.SolarisMotif Solaris Project Makefile
Makefile.LinuxMotif Linux Project Makefile
Download the Motif_CPP files

Download the files for all languages




Development licensing Deployment licensing
Engine Developer Kit Engine