Visit Gigasoft's Web Site
 ProEssentials v10 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 .Net  function PeFuction.GetHotSpot() or via CPP  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

 

C#.NET Example Code

// From example 014 Form2, MouseMove event handler located in Form1
Gigasoft.ProEssentials.Structs.HotSpotData ds = Pego1.PeFunction.GetHotSpot();

if (ds.Type == HotSpotType.DataPoint)
    this.Text = "DataPoint value " + Pego1.PeData.Y[ds.Data1, ds.Data2].ToString();
else if (ds.Type == HotSpotType.Subset)
    this.Text = "Subset Legend is " + Pego1.PeString.SubsetLabels[ds.Data1];
else if (ds.Type == HotSpotType.Point)
    this.Text = "Point Label is " + Pego1.PeString.PointLabels[ds.Data1];
else
{
    // if no hot spot type, lets find subset point closest to mouse location //'
    System.Drawing.Point pt = Pego1.PeUserInterface.Cursor.LastMouseMove;
    System.Drawing.Point p = Pego1.PeFunction.SearchSubsetPointIndex(pt.X, pt.Y);
    if (p.X >= 0)  // function succeeded in finding a subset point index  
    {
         string s = String.Format("Closest Subset Point s={0}", p.X);
         s += String.Format(", p={0}", p.Y);
         this.Text = s;
    }
    else
        this.Text = "No Hot Spot";
}
 

 

The following VBA 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;