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


ITOCControl2.HitTest Method (ArcObjects .NET 10.6 SDK)
ArcObjects Library Reference (Controls)  

ITOCControl2.HitTest Method

Returns the item in the TOCControl at the specified coordinates.

[Visual Basic .NET]
Public Sub HitTest ( _
    ByVal X As Integer, _
    ByVal Y As Integer, _
    ByRef ItemType As esriTOCControlItem, _
    ByRef BasicMap As IBasicMap, _
    ByRef Layer As ILayer, _
    ByRef Unk As Object, _
    ByRef Data As Object _
)
[C#]
public void HitTest (
    int X,
    int Y,
    ref esriTOCControlItem ItemType,
    ref IBasicMap BasicMap,
    ref ILayer Layer,
    ref object Unk,
    ref object Data
);
[C++]
HRESULT HitTest(
  long X,
  long Y,
  esriTOCControlItem* ItemType,
  IBasicMap** BasicMap,
  ILayer** Layer,
  IUnknown Pointer* Unk,
  Variant* Data
);
[C++]

Parameters X [in]
X is a parameter of type long Y [in]
Y is a parameter of type long ItemType [in, out]
ItemType is a parameter of type esriTOCControlItem* BasicMap [in, out]
BasicMap is a parameter of type IBasicMap** Layer [in, out]
Layer is a parameter of type ILayer** Unk [in, out]
Unk is a parameter of type IUnknown* Data [in, out]
Data is a parameter of type VARIANT*

Product Availability

Available with ArcGIS Engine.

Description

x is the X coordinate, in pixels, where the mouse button was pressed referenced against the origin (0, 0) of the TOCControl (the top left hand corner).

y is the Y coordinate, in pixels, where the mouse button was pressed referenced against the origin (0, 0) of the TOCControl (the top left hand corner).

ItemType specifies an enumeration indicating the type of item (none, map, layer, heading or legend class).

Map specifies an IMap object.

Layer specifies an ILayer object.

Unk specifies an ILegendGroup object.

Data specifies a long indicating the index of the legend class within the legend group. Use this index in conjunction with the legend group to obtain a particular legend class. An index of -1 refers to the heading if it is present.

[C#]
IBasicMap map=null;
ILayer layer=null;
Object other=null;
Object index=null;
esriTOCControlItem item=esriTOCControlItem.esriTOCControlItemNone;

axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
[Visual Basic .NET]
Dim pMap As IMap=Nothing
Dim pLayer As ILayer=Nothing
Dim pOther As Object=Nothing
Dim pItem As esriTOCControlItem
Dim pIndex As Object=Nothing

AxTOCControl1.HitTest(e.x, e.y, pItem, pMap, pLayer, pOther, pIndex)

See Also

ITOCControl2 Interface

.NET Samples

Displaying a TOCControl context menu (Code Files: TOCContextMenuForm) | Schematics Engine application (Code Files: MainForm)