Dockable Window

Last Modified:08/15/2002

The Dockable Window example shows how to create a custom dockable window for use in ArcMap. A dockable window is a window that can exist in a floating state or be attached to the main application window. The table of contents in ArcMap is a good example of a dockable window. The dockable window in this example is a listbox that shows how many features are selected in each layer in the active map. This example also includes a command called SelCount Dockable Window that is used to toggle the visibility of the dockable window.

The class for the dockable window, DockWin.cls, implements the IDockableWindowDef interface. This interface defines the properties of the dockable window. This class also listens to MxDocument events (IDocumentEvents), Map events (IActiveViewEvents), and PageLayout events (IActiveViewEvents). When the IActiveView SelectionChanged event occurs, the listbox on the dockable window is updated.

The class for the command, cmdDockWin, implements the ICommand interface. This interface defines the properties of a command that can be used in ArcMap. This command uses the IDockableWindowManager interface to get a reference to the dockable window created in this example.

How to use:
  1. If using the VB 6 sample, register the dll on your machine. Use Categories to add the dll the appropriate component categories. Add the Dockwin class to 'ESRI Mx Dockable Windows' and cmdDockWin class to 'ESRI Mx Commands'.
  2. If using either.NET sample, open the .NET solution file and build the project.
  3. Start ArcMap and add some data.
  4. From the 'Developer Samples' command category on the Customize dialog, drag the command to any toolbar.
  5. Click the command. The dockable window should appear.
  6. Try docking the window in various locations on the ArcMap application window. Try floating the dockable window.
  7. Select some features on the map. The selection count for each layer should be displayed in the dockable window.


Difficulty: Intermediate

Visual Basic Visual Basic.NET C#
File Description
DockWin.cls Class file demonstrating how to create a custom dockable window.
cmdDockWin.cls Class file demonstrating how to create a custom command.
frmDockWin.frm Visual Basic form that contains the listbox used by the custom dockable window.
DockableWindow.vbp The project file for the custom dockable window and command.
DockableWindow.dll The compiled project.

Key Interfaces: IDockableWindowDef, IDockableWindowManager, IDockableWindow, ICommand, IActiveViewEvents, IDocumentEvents