property List.ItemFromPoint (X as OLE_XPOS_PIXELS, Y as OLE_YPOS_PIXELS, ColIndex as Long, HitTestInfo as HitTestInfoEnum) as Long
Retrieves the item from point.

   X as OLE_XPOS_PIXELS A single expression that indicates the X position in client coordinate.  
   Y as OLE_YPOS_PIXELS A single expression that indicates the Y position in client coordinate.  
   ColIndex as Long A long value that indicates the column's index.  
   HitTestInfo as HitTestInfoEnum A HitTestInfoEnum expression that determines on return, the position of the cursor within the cell.  
   Long A long expression that indicates item's index from point (X,Y)   

Use the ItemFromPoint property to get the item from the point specified by the {X,Y}. The X and Y coordinates are expressed in client coordinates, so a conversion must be done in case your coordinates are relative to the screen or to other window. If the X parameter is -1 and Y parameter is -1 the ItemFromPoint property determines the index of the item from the cursor. Use the ColumnFromPoint property to retrieve the column from cursor. Use the SelectableItem property to specify the user can select an item.

The following VB sample displays the cell over the cursor:

Private Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim c As Long, i As Long, hit As HitTestInfoEnum
    With List1
        i = .ItemFromPoint(X / Screen.TwipsPerPixelX, Y / Screen.TwipsPerPixelY, c, hit)
        If (i >= 0) Then
            If (c >= 0) Then
                Debug.Print .Items.Caption(i, c)
            End If
        End If
    End With
End Sub

The following C++ sample displays the cell over the cursor:

void OnMouseMoveList1(short Button, short Shift, long X, long Y) 
	long c = 0, hit = 0, i = m_list.GetItemFromPoint( X, Y, &c, &hit );
	if ( i >= 0 )
		CItems items = m_list.GetItems();
		CString strCaption = V2S( &items.GetCaption( i, COleVariant( c ) ) );
		OutputDebugString( strCaption );

The following VB.NET sample displays the cell over the cursor:

Private Sub AxList1_MouseMoveEvent(ByVal sender As Object, ByVal e As AxEXLISTLib._IListEvents_MouseMoveEvent) Handles AxList1.MouseMoveEvent
    Dim c As Integer, hit As EXLISTLib.HitTestInfoEnum
    Dim i As Integer = AxList1.get_ItemFromPoint(e.x, e.y, c, hit)
    If (i >= 0) Then
        With AxList1.Items
            Debug.Write(.Caption(i, c))
        End With
    End If
End Sub

The following C# sample displays the cell over the cursor:

private void axList1_MouseMoveEvent(object sender, AxEXLISTLib._IListEvents_MouseMoveEvent e)
	EXLISTLib.HitTestInfoEnum hit;
	int c = 0, i = axList1.get_ItemFromPoint(e.x, e.y, out c, out hit);
	if (i >= 0)
		System.Diagnostics.Debug.WriteLine(axList1.Items.get_Caption(i, c).ToString());

The following VFP sample displays the cell over the cursor:

*** ActiveX Control Event ***
LPARAMETERS button, shift, x, y

local c, i, hit
With thisform.List1
	c = 0
	hit = 0
	i = .ItemFromPoint(x, y, @c, @hit)
    If (i >= 0)
 		wait window nowait .Items.Caption(i, c)

Send comments on this topic.
1999-2017 Exontrol.COM, Software. All rights reserved.