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


Workaround for ink commands and Microsoft Visual Studio .NET (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > Developing with ArcGIS > Building stand-alone applications > Using the Winforms ArcGIS Engine controls > Workaround for ink commands and Microsoft Visual Studio .NET (ArcObjects .NET 10.6 SDK)

Workaround for ink commands and Microsoft Visual Studio .NET


Summary
Using the ArcGIS Engine controls and ink commands in Microsoft Visual Studio .NET can lead to application instability in the following cases—when used in conjunction with the Microsoft Visual Studio .NET SplitContainer or Splitter controls, and when the Microsoft Visual Studio .NET Dock or Anchor properties are set on an ArcGIS Engine control. This topic discusses the problem and provides two possible workarounds to help mitigate the issue.

In this topic


About ink commands and Microsoft Visual Studio .NET

Using the ArcGIS Engine MapControl or PageLayoutControl in conjunction with the Microsoft Visual Studio .NET SplitContainer or Splitter controls in the System.Windows.Forms namespace can lead to application instability. Instability occurs when an application is resized, before a ControlsInkHighlightTool or ControlsInkPenTool is set as the CurrentTool on the ToolbarControl.
This instability is caused by an incompatibility between the Microsoft Visual Studio .NET SplitContainer and Splitter controls, and Microsoft Ink. For more information, see the InkOverlay.SetWindowInputRectangle method on the Microsoft Developer Network (MSDN) Web site.
The same instability can occur when the Dock or Anchor properties (in the System.Windows.Forms namespace) are set on an ArcGIS Engine control.

Workaround 1

Do not use the Microsoft Visual Studio .NET SplitContainer or Splitter controls, and do not set the Dock or Anchor properties on an ArcGIS Engine control in an application that uses a ControlsInkHighlightTool or ControlsInkPenTool.

Workaround 2

If the Microsoft Visual Studio .NET SplitContainer or Splitter controls are used in an application, set a ControlsInkHighlightTool or ControlsInkPenTool as the CurrentTool on the ToolbarControl before the application can be resized. For example, the following code example can be added to the Form Load event:
 
[VB.NET]
'The ControlsInkHighlightTool and the ControlsInkPenTool implement
'the ICommandSubType interface, and contain three subtyped commands.
'To find a particular command, a unique identifier (UID) object is used.
Dim uID As New ESRI.ArcGIS.esriSystem.UID
uID.Value="esriControls.ControlsInkHighlightTool"
uID.SubType=1

'Find the command on the ToolbarControl.
Dim i As Integer=axToolbarControl1.Find(uID)
'Cast from ICommand to ITool.
Dim tool As ESRI.ArcGIS.SystemUI.ITool=CType(axToolbarControl1.GetItem(i).Command, ESRI.ArcGIS.SystemUI.ITool)
'Update the commands on the ToolbarControl.
axToolbarControl1.Update()
'Set the tool to be the CurrentTool.
axToolbarControl1.CurrentTool=tool
[C#]
//The ControlsInkHighlightTool and the ControlsInkPenTool implement
//the ICommandSubType interface, and contain three subtyped commands. 
//To find a particular command, a unique identifier (UID) object is used.
ESRI.ArcGIS.esriSystem.UID uID=new ESRI.ArcGIS.esriSystem.UID();
uID.Value="esriControls.ControlsInkHighlightTool";
uID.SubType=1;

//Find the command on the ToolbarControl.
int i=axToolbarControl1.Find(uID);
//Cast from ICommand to ITool.
ESRI.ArcGIS.SystemUI.ITool tool=axToolbarControl1.GetItem(i).Command as
    ESRI.ArcGIS.SystemUI.ITool;
//Update the commands on the ToolbarControl.
axToolbarControl1.Update();
//Set the tool to be the CurrentTool.
axToolbarControl1.CurrentTool=tool;






Development licensing Deployment licensing
Engine Developer Kit Engine
ArcGIS for Desktop Basic
ArcGIS for Desktop Standard
ArcGIS for Desktop Advanced