property Gantt.ItemFromPoint (X as OLE_XPOS_PIXELS, Y as OLE_YPOS_PIXELS, ColIndex as Long, HitTestInfo as HitTestInfoEnum) as HITEM

Retrieves the item from the cursor.

TypeDescription
X as OLE_XPOS_PIXELS A single that specifies the current X location of the mouse pointer. The x values is always expressed in client coordinates.
Y as OLE_YPOS_PIXELS A single that specifies the current Y location of the mouse pointer. The y values is always expressed in client coordinates.
ColIndex as Long A long expression that indicates on return, the column where the point belongs. If the return value is zero, the ColIndex may indicate the handle of the cell ( inner cell ).
HitTestInfo as HitTestInfoEnum A HitTestInfoEnum expression that determines on return, the position of the cursor within the cell.
HITEM A long expression that indicates the item's handle where the point is.

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 handle of the item from the cursor. Use the ColumnFromPoint property to retrieve the column from cursor. Use the DateFromPoint property to specify the date from the cursor. Use the SelectableItem property to specify the user can select an item. Use the LevelFromPoint property to retrieve the index of the level from the cursor.

The following VB sample prints the cell's caption from the cursor ( if the control contains no inner cells. Use the SplitCell property to insert inner cells ) :

Private Sub Gantt1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    On Error Resume Next
    ' Converts the container coordinates to client coordinates
    X = X / Screen.TwipsPerPixelX
    Y = Y / Screen.TwipsPerPixelY
    Dim h As HITEM
    Dim c As Long
    Dim hit As EXGANTTLibCtl.HitTestInfoEnum
    ' Gets the item from (X,Y)
    h = Gantt1.ItemFromPoint(X, Y, c, hit)
    If Not (h = 0) Then
        Debug.Print Gantt1.Items.CellCaption(h, c) & " HT = " & hit
    End If
End Sub

The following VB sample displays the cell's caption from the cursor ( if the control contains inner cells ):

Private Sub Gantt1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    On Error Resume Next
    ' Converts the container coordinates to client coordinates
    X = X / Screen.TwipsPerPixelX
    Y = Y / Screen.TwipsPerPixelY
    Dim h As HITEM
    Dim c As Long
    Dim hit As EXGANTTLibCtl.HitTestInfoEnum
    ' Gets the item from (X,Y)
    h = Gantt1.ItemFromPoint(X, Y, c, hit)
    If Not (h = 0) Or Not (c = 0) Then
        Debug.Print Gantt1.Items.CellCaption(h, c) & " HT = " & hit
    End If
End Sub

The following VB sample displays the index of icon being clicked:

Private Sub Gantt1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim i As HITEM, h As HitTestInfoEnum, c As Long
    With Gantt1
        i = .ItemFromPoint(X / Screen.TwipsPerPixelX, Y / Screen.TwipsPerPixelY, c, h)
    End With
    If (i <> 0) or ( c <> 0 ) Then
        If exHTCellIcon = (h And exHTCellIcon) Then
            Debug.Print "The index of icon being clicked is: " & (h And &HFFFF0000) / 65536
        End If
    End If
End Sub

The following C# sample displays the caption of the cell being double clicked ( including the inner cells ): 

	EXGANTTLib.HitTestInfoEnum hit;
	int c = 0, h = axGantt1.get_ItemFromPoint( e.x, e.y, out c, out hit );
	if ( ( h != 0 ) || ( c != 0 ) )
		MessageBox.Show( axGantt1.Items.get_CellCaption( h, c ).ToString() );

The following VC sample displays the caption of the cell being clicked:

#include "Items.h"

static CString V2S( VARIANT* pv, LPCTSTR szDefault = _T("") )
{
	if ( pv )
	{
		if ( pv->vt == VT_ERROR )
			return szDefault;

		COleVariant vt;
		vt.ChangeType( VT_BSTR, pv );
		return V_BSTR( &vt );
	}
	return szDefault;
}

void OnMouseDownGantt1(short Button, short Shift, long X, long Y) 
{
	long c = 0, hit = 0, hItem = m_gantt.GetItemFromPoint( X, Y, &c, &hit );
	if ( ( hItem != 0 ) || ( c != 0 ) )
	{
		CItems items = m_gantt.GetItems();
		COleVariant vtItem( hItem ), vtColumn( c );
		CString strCaption = V2S( &items.GetCellCaption( vtItem, vtColumn ) ), strOutput;
		strOutput.Format( "Cell: '%s', Hit = %08X\n", strCaption, hit );
		OutputDebugString( strOutput );
	}
}

The following VB.NET sample displays the caption from the cell being clicked:

Private Sub AxGantt1_MouseDownEvent(ByVal sender As Object, ByVal e As AxEXGANTTLib._IGanttEvents_MouseDownEvent) Handles AxGantt1.MouseDownEvent
    With AxGantt1
        Dim i As Integer, c As Integer, hit As EXGANTTLib.HitTestInfoEnum
        i = .get_ItemFromPoint(e.x, e.y, c, hit)
        If (Not (i = 0) Or Not (c = 0)) Then
            Debug.WriteLine("Cell: " & .Items.CellCaption(i, c) & " Hit: " & hit.ToString())
        End If
    End With
End Sub

The following C# sample displays the caption from the cell being clicked:

private void axGantt1_MouseDownEvent(object sender, AxEXGANTTLib._IGanttEvents_MouseDownEvent e)
{
	int c = 0;
	EXGANTTLib.HitTestInfoEnum hit;
	int i = axGantt1.get_ItemFromPoint( e.x, e.y, out c,out hit );
	if ( ( i != 0 ) || ( c != 0 ) )
	{
		string s = axGantt1.Items.get_CellCaption( i,c ).ToString();
		s = "Cell: " + s + ", Hit: " + hit.ToString();
		System.Diagnostics.Debug.WriteLine( s );
	}
}

The following VFP sample displays the caption from the cell being clicked ( the code should be in the Gantt1.MouseDown event ):

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

local c, hit
c = 0
hit = 0
with thisform.Gantt1
	.Items.DefaultItem = .ItemFromPoint( x, y, @c, @hit )
	if ( .Items.DefaultItem <> 0 ) or ( c <> 0 )
		wait window nowait .Items.CellCaption( 0, c ) + " " + Str( hit )
	endif
endwith