Hide

SftTree/OCX 7.5 - ActiveX Tree Control

Display
Print

HitTestPix Method, SftTreeItems Object

Returns the index of the item found at given coordinates.

Syntax

VB.NETItemIndex = object.HitTestPix(ByVal XPosPix As OLE_XPOS_PIXELS, ByVal YPosPix As OLE_YPOS_PIXELS) As Integer
VBItemIndex = object.HitTestPix(ByVal XPosPix As OLE_XPOS_PIXELS, ByVal YPosPix As OLE_YPOS_PIXELS) As Long
C#.NETint ItemIndex = object.HitTestPix(OLE_XPOS_PIXELS XPosPix, OLE_YPOS_PIXELS YPosPix);
VC++long ItemIndex = object->HitTestPix(OLE_XPOS_PIXELS XPosPix, OLE_YPOS_PIXELS YPosPix);
CHRESULT object->raw_HitTestPix(OLE_XPOS_PIXELS XPosPix, OLE_YPOS_PIXELS YPosPix, long* ItemIndex);

object

A SftTreeItems object.

XPosPix

The x coordinate to be tested in pixels.

YPosPix

The y coordinate to be tested in pixels.

ItemIndex

Returns the index of the item found at given coordinates. -1 is returned if no item is found.

Comments

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

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

If an item is found at the coordinates (xPosPix, yPosPix), 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 HitTestPix method can be used during a DragOver or OLEDragOver event to determine which item is currently the target of the drag & drop operation. The CalcCellFromPosPix or CalcIndexFromPosPix methods can also be used.

Examples

VB.NET

        AxSftTree1.Headers.GetPositionPix(L, T, W, H)
        If e.x >= L And e.x < L + W And e.y >= T And e.y <= T + H Then
            HeaderMenu(PointToClient(P))
            Return
        End If

        ' determine item right-clicked
        Dim ItemIndex As Integer
        ItemIndex = AxSftTree1.Items.HitTestPix(e.x, e.y)
        If ItemIndex >= 0 And ItemIndex < AxSftTree1.Items.Count Then
            AxSftTree1.Items.Current = ItemIndex
            AxSftTree1.get_Item(ItemIndex).Selected = True
            AxSftTree1.CancelMode()
            ItemContextMenu.Show(Me, PointToClient(P))
        End If
    End Sub

C#

            int l, t, h, w;
            axSftTree1.Headers.GetPositionPix(out l, out t, out w, out h);
            if (e.x >= l && e.x < l + w && e.y >= t && e.y <= t + h) {
                HeaderMenu(PointToClient(point));
                return;
            }

            // determine item right-clicked
            int ItemIndex = axSftTree1.Items.HitTestPix(e.x, e.y);
            if (ItemIndex >= 0 && ItemIndex < axSftTree1.Items.Count) {
                axSftTree1.Items.Current = ItemIndex;
                axSftTree1.get_Item(ItemIndex).Selected = true;
                axSftTree1.CancelMode();
                ItemContextMenu.Show(this, PointToClient(point));
            }
        }

C++

    m_vTree->Headers->GetPositionPix(&l, &t, &w, &h);
    if (x >= l && x < l + w && y >= t && y <= t + h) {
        HeaderMenu(pt);
        return;
    }

    // determine item right-clicked
    long ItemIndex;
    ItemIndex = m_vTree->Items->HitTestPix(x, y);
    if (ItemIndex >= 0 && ItemIndex < m_vTree->Items->Count) {
        m_vTree->Items->Current = ItemIndex;
        m_vTree->Item[ItemIndex]->Selected = VARIANT_TRUE;
        ItemMenu(pt);
        return;
    }
}

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.