property Chart.BarFromPoint (X as OLE_XPOS_PIXELS, Y as OLE_YPOS_PIXELS) as Variant
Retrieves the bar from point.

 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.  
   Variant A VARIANT expression that indicates the key of the bar from the cursor.  
The BarFromPoint property gets the bar from point. If the X parameter is -1 and Y parameter is -1 the BarFromPoint property determines the key of the bar from the cursor. Use the ItemBar property to access properties of the bar from the point. The DateFromPoint property retrieves the date from the cursor, only if the cursor hovers the chart's area. Use the ItemFromPoint property to get the cell/item from the cursor. Use the ColumnFromPoint property to retrieve the column from cursor. Use the LinkFromPoint property to get the link from the point.  Use the FormateDate property to format a date. Use the DrawDateTicker property to draw a ticker as cursor hovers the chart's area. Use the LevelFromPoint property to retrieve the index of the level from the cursor.

The following VB sample displays the key of the bar from the cursor:

Private Sub G2antt1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    With G2antt1.Chart
        Debug.Print .BarFromPoint(-1, -1)
    End With
End Sub

The following VB sample displays the start data of the bar from the point:

Private Sub G2antt1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    With G2antt1
        Dim h As HITEM, c As Long, hit As HitTestInfoEnum
        h = .ItemFromPoint(-1, -1, c, hit)
        If Not (h = 0) Then
            Dim k As Variant
            k = .Chart.BarFromPoint(-1, -1)
            If Not IsEmpty(k) Then
                Debug.Print .Items.ItemBar(h, k, exBarStart)
            End If
        End If
    End With
End Sub

The following C++ sample displays the start data of the bar from the point:

#include "Items.h"
#include "Chart.h"

CString V2Date( VARIANT* pvtValue )
{
	COleVariant vtDate;
	vtDate.ChangeType( VT_BSTR, pvtValue );
	return V_BSTR( &vtDate );
}

void OnMouseDownG2antt1(short Button, short Shift, long X, long Y) 
{
	long c = 0, hit = 0, h = m_g2antt.GetItemFromPoint( -1, -1, &c, &hit );
	if ( h != 0 )
	{
		COleVariant vtKey = m_g2antt.GetChart().GetBarFromPoint( -1, -1 );
		if ( V_VT( &vtKey ) != VT_EMPTY )
		{
			COleVariant vtStart = m_g2antt.GetItems().GetItemBar( h, vtKey, 1 /*exBarStart*/ );
			OutputDebugString( V2Date( &vtStart ) );
		}
	}
}

The following VB.NET sample displays the start data of the bar from the point:

Private Sub AxG2antt1_MouseDownEvent(ByVal sender As Object, ByVal e As AxEXG2ANTTLib._IG2anttEvents_MouseDownEvent) Handles AxG2antt1.MouseDownEvent
    With AxG2antt1
        Dim c As Long, hit As EXG2ANTTLib.HitTestInfoEnum, h As Integer = .get_ItemFromPoint(-1, -1, c, hit)
        If Not (h = 0) Then
            Dim k As Object
            k = .Chart.BarFromPoint(-1, -1)
            If Not k Is Nothing Then
                System.Diagnostics.Debug.WriteLine(.Items.ItemBar(h, k, EXG2ANTTLib.ItemBarPropertyEnum.exBarStart))
            End If
        End If
    End With
End Sub

The following C# sample displays the start data of the bar from the point:

private void axG2antt1_MouseDownEvent(object sender, AxEXG2ANTTLib._IG2anttEvents_MouseDownEvent e)
{
	int c = 0;
	EXG2ANTTLib.HitTestInfoEnum hit = EXG2ANTTLib.HitTestInfoEnum.exHTCell;
	int h = axG2antt1.get_ItemFromPoint(-1, -1, out c, out hit);
	if (h != 0)
	{
		object k = axG2antt1.Chart.get_BarFromPoint(-1, -1);
		if (k != null)
			System.Diagnostics.Debug.WriteLine( axG2antt1.Items.get_ItemBar( h, k, EXG2ANTTLib.ItemBarPropertyEnum.exBarStart ) );
	}
}

The following VFP sample displays the start data of the bar from the point:

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

With thisform.G2antt1
	local h, c, hit
    h = .ItemFromPoint(-1, -1, c, hit)
    If (h # 0) Then
        local k
        k = .Chart.BarFromPoint(-1, -1)
        If !Empty(k) Then
            ? .Items.ItemBar(h, k, 1)
        EndIf
    EndIf
EndWith


Send comments on this topic.
© 1999-2008 Exontrol Inc, Software. All rights reserved.