Hide

SftTree/OCX 7.5 - ActiveX Tree Control

Display
Print

HitTest Method, SftTreeItems Object

Returns the index of the item found at given coordinates.

Syntax

VB.NETItemIndex = object.HitTest(ByVal xPos As Single, ByVal yPos As Single) As Integer
VBItemIndex = object.HitTest(ByVal xPos As Single, ByVal yPos As Single) As Long
C#.NETint ItemIndex = object.HitTest(float xPos, float yPos);
VC++long ItemIndex = object->HitTest(float xPos, float yPos);
CHRESULT object->raw_HitTest(float xPos, float yPos, long* ItemIndex);

object

A SftTreeItems object.

xPos

The x coordinate to be tested. The units used depend on the container (Visual Basic, Visual C++, etc.) and the coordinate system used.

yPos

The y coordinate to be tested. The units used depend on the container (Visual Basic, Visual C++, etc.) and the coordinate system used.

ItemIndex

Returns the zero-based index of the item found at the specified coordinates. -1 is returned if no item is found.

Comments

The HitTest method returns the index of the item found at given coordinates.

The HitTest and Items.HitTestPix methods are synonyms, but may use different coordinate systems.

If an item is found at the coordinates (xPos, yPos), the zero-based index of the item is returned. If the specified coordinates are located in the row/column header or column header area, -1 is returned. If the coordinates are located in the tree control's client area, below the last item displayed, the zero-based index of the last item + 1 is returned, which is equal to the number of items in the tree control.

The HitTest method can be used during a DragOver or OLEDragOver event to determine which item is currently the target of the drag & drop operation. The CalcCellFromPos or CalcIndexFromPos methods can also be used.

Examples

VB6

    SftTree1.Headers.GetPosition l, t, w, h
    If X >= l And X < l + w And Y >= t And Y <= t + h Then
        HeaderMenu
        Exit Sub
    End If

    ' determine item right-clicked
    Dim ItemIndex As Long
    ItemIndex = SftTree1.Items.HitTest(X, Y)
    If ItemIndex >= 0 And ItemIndex < SftTree1.Items.Count Then
        SftTree1.Items.Current = ItemIndex
        SftTree1.Item(ItemIndex).Selected = True
        SftTree1.CancelMode
        PopupMenu MenuForm.ItemPopup
    End If
End Sub

See Also SftTreeItems Object | Object Hierarchy


Last Updated 08/13/2020 - (email)
© 2024 Softel vdm, Inc.


Spring Break!

Our offices will be closed this week (March 18 through March 22).

We'll be back March 24 to address any pending sales and support issues.