Visit Gigasoft's Web Site
 ProEssentials v9 Help

Common Question 23

How do I know when the mouse is over a Hot-Spot?

If you want to know if the mouse is located over a hot-spot, without the user having to click, you use the PEgethotspot function.

 

See example 014 in our demo for examples of this feature.

 

.NET, OCX, VCL developers will use the object's MouseMove event which is part of the standard visual interface.

 

C/C++ developers will respond to the PEWN_MOUSEMOVE notification code and

 

VB.NET Example Code

Dim hsType As Int32
Dim extra1 As Int32
Dim extra2 As Int32
Dim pX As Int32
Dim pY As Int32
Dim pt As System.Drawing.Point
Dim ds As Gigasoft.ProEssentials.Structs.HotSpotData

 

'// get last mouse location within control //'
pt = Pego1.PeUserInterface.Cursor.LastMouseMove()
pX = pt.X
pY = pt.Y

'// Calls to fill hot spot data structure with hot spot data at given x and y
Pego1.PeFunction.GetHotSpot(pX, pY)

 

'// Calls PEgethotspot //'
ds = Pego1.PeFunction.GetHotSpotData()
hsType = ds.Type
extra1 = ds.Data1
extra2 = ds.Data2

 

If (hsType = HotSpotType.DataPoint) Then
  Me.Text = "DataPoint value " + Str$(Pego1.PeData.Y(extra1, extra2))
ElseIf (hsType = HotSpotType.Subset) Then
  Me.Text = "Subset Legend is " + Pego1.PeString.SubsetLabels(extra1)
ElseIf (hsType = HotSpotType.Point) Then
  Me.Text = "Point Label is " + Pego1.PeString.PointLabels(extra1)
Else
  Me.Text = "No Hot Spot"
End If

 

The following VB6 code is an example of how you can determine if the mouse is over a hot-spot.

Dim hsType As Integer
Dim extra1 As Long
Dim extra2 As Long

'// get last mouse location within control //'
Pego1.GetLastMouseMove pX, pY

'// fill hot spot data structure with hot spot data at given x and y
Pego1.PEgethotspot pX, pY

'// Calls PEgethotspot //'
Pego1.GetHotSpotData hsType, extra1, extra2

If (hsType = PEHS_DATAPOINT) Then
  Form2.Caption = "DataPoint value " + Str$(Pego1.YData(extra1, extra2))
ElseIf (hsType = PEHS_SUBSET) Then
  Form2.Caption = "Subset Legend is " + Pego1.SubsetLabels(extra1)
ElseIf (hsType = PEHS_POINT) Then
  Form2.Caption = "Point Label is " + Pego1.PointLabels(extra1)
Else
  Form2.Caption = "No Hot Spot"
End If

 

C++ Example

POINT pt;
HOTSPOTDATA hsd;
TCHAR buffer[128];
TCHAR buffer2[64];

 

// get last mouse location within control //
PEvget(m_hPE, PEP_ptLASTMOUSEMOVE, &pt);

 

// call PEgethotspot //
PEgethotspot(m_hPE, pt.x, pt.y);

// now look at HotSpotData structure //
PEvget(m_hPE, PEP_structHOTSPOTDATA, &hsd);

if (hsd.nHotSpotType == PEHS_DATAPOINT)
{
  // get ydata value at hot spot //
  float yvalue;
  PEvgetcellEx(m_hPE, PEP_faYDATA, hsd.w1, hsd.w2, &yvalue);
  _stprintf(buffer, TEXT("DataPoint value %.2f"), yvalue);
}
else if (hsd.nHotSpotType == PEHS_SUBSET)
{
  PEvgetcell(m_hPE, PEP_szaSUBSETLABELS, hsd.w1, buffer2);
  _stprintf(buffer, TEXT("Subset Legend is %s"), buffer2);
}
else if (hsd.nHotSpotType == PEHS_POINT)
{
  PEvgetcell(m_hPE, PEP_szaPOINTLABELS, hsd.w1, buffer2);
  _stprintf(buffer, TEXT("Point Label is %s"), buffer2);
}
else
  lstrcpy(buffer, TEXT("No Hot Spot"));

 

CWnd* pParent = GetParent()->GetParent();
if (pParent) {pParent->SetWindowText(buffer);}

pParent = AfxGetMainWnd();
if (pParent) {pParent->SetWindowText(TEXT("PEgethotspot"));}

 

return TRUE;