Contained Object


The sample illustrates the use of COM containment to achieve code reuse. The Map Zoom In tool included with ArcMap is contained by a visual basic object. The majority of the properties and methods of the VB object are simply passed to the contained object.

How to use:
  1. Open the sample, and compile it to make prjContZoom.dll.
  2. In the Customize dialog, click on 'Add from file' and select this dll.
  3. Under the Commands tab, select the My Zoom In command from the Developer Samples category, and drag it on to a toolbar. Dismiss the Customize dialog.
  4. Click on the tool, and start using it.
  5. Inspect the code and note the creation of the contained object, and its subsequent use.


Difficulty: Intermediate

Visual Basic
File Description
clsContZoom.cls VB Class containing the ESRI Zoom In tool.
prjContZoom.vbp Project for the contained object dll.
prjContZoom.dll DLL file for the contained object.

Key CoClasses: ZoomInTool
Key Interfaces: ICommand, ITool