This document is archived and information here might be outdated.  Recommended version.


How to handle ActiveX controls embedded in a dockable window (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Extending ArcObjects > Application framework customizations > Creating dockable windows > How to handle ActiveX controls embedded in a dockable window

How to handle ActiveX controls embedded in a dockable window


Handling ActiveX controls embedded in a dockable window

You can host an ActiveX control on a Windows Form by using Visual Studio to import the control, which generates a .NET wrapper class for it. By doing this, the control can have the same design time and programming support as other Windows Form controls.
ArcGIS Engine controls, such as MapControl, PageLayoutControl, and ArcReaderControl, are all developed as ActiveX controls that have been imported into .NET as Esri ArcGIS assemblies. You do not have to import these controls yourself.
Developing with ArcGIS Engine controls requires an ArcGIS Engine Developer Kit license.
Although the generated .NET wrapper class handles most of the communication between .NET and the ActiveX control, you are responsible for managing the lifetime of the control by making sure it has been disposed of properly, especially when developing against ArcGIS Desktop applications. Otherwise, it can throw an exception when the application shuts down.
When implementing a dockable window, call the System.Windows.Forms.Control.Dispose method in IDockableWindowDef.OnDestroy to make sure it is properly disposed of.
Follow theses steps to add a dockable window implementation to an existing project:
  1. Create a project from one of the ArcGIS Desktop Class Library Project templates.
  2. Add the Dockable Window item template under the ArcGIS Desktop category to the project. Choose the application option that matches the debugging application of the project. For more information about item templates, see Using item templates to extend ArcObjects.
  3. Replace the label on the dockable window with an ActiveX control; for example, drag and drop the MapControl under the ArcGIS Windows Form from the toolbox.
Using the MapControl requires an ArcGIS Engine Developer Kit license.
  1. In the OnDestroy method, add the dispose code. The following code disposes the MapControl called axMapControl1 on the user control:
[C#]
void IDockableWindowDef.OnDestroy()
{
    axMapControl1.Dispose();
    'or call this.Dispose();
}
[VB.NET]
Public Sub OnDestroy() Implements ESRI.ArcGIS.Framework.IDockableWindowDef.OnDestroy
    axMapControl1.Dispose()
    'or call Me.Dispose()
End Sub
When you have a .NET form or component referencing an ActiveX control, dispose must be called before the application shuts down. In most cases, there is a definite exit point when the dialog box is closed. For example, ActiveX controls on a modal form can be properly disposed of right after Form.ShowDialog is called. On a dockable window, dispose the control at OnDestroy; on a property page, dispose at IComPropertyPage.Deactivate. The exception is a modeless form that should have a supplementary extension to manage the lifetime of the ActiveX control at IExtension.Shutdown.


See Also:

Windows Forms ActiveX Control Importer (Aximp.exe)




Development licensing Deployment licensing
ArcGIS Desktop Basic ArcGIS Desktop Basic
ArcGIS Desktop Standard ArcGIS Desktop Standard
ArcGIS Desktop Advanced ArcGIS Desktop Advanced