Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

oncursorchange problem...

i'd like to display location of cursor which is movable along the plot...

so i wrote this code....

int x=0;
void CTraceDlg::CursorChangeCwgraph1(long* CursorIndex, VARIANT* XPos, VARIANT* YPos, BOOL* bTracking)
{
CString xpos;
CString ypos;

xpos.Format("%d", XPos->dblVal);
SetDlgItemText(IDC_SXPOS, xpos);
ypos.Format("%d", YPos->dblVal);
SetDlgItemText(IDC_SYPOS, ypos);
//xpos.Format("%i", x++); // for checking..
//SetDlgItemText(IDC_SXPOS, xpos);
}

where IDC_SXPOS and IDC_SYPOS are static text IDs....
but somehow it only shows 0,0 on the screen...
i tested with a global int x to see if cursor change is working, and it worked...

what should i do to get the coordination...
could you please give me in codes....

Thanks...

Message Edited by codekin on 06-30-2005 05:45 PM

0 Kudos
Message 1 of 2
(2,976 Views)

Hi Codekin, There is a great example that ships with Measurement Studio that shows the cursor position as you move along the graph. You can find this example at: C:\Program Files\National Instruments\MeasurementStudio\VC\Examples\Ui\Graph\Cursors Inside CursorsDlg.cpp

there is code that reads the current cursor position

void CCursorsDlg::OnSetpos()
{
 //set the cursor positions
 m_Graph.GetCursors().Item(1).XPosition = m_SetxPos.Value;
 if (m_Graph.GetCursors().Item(1).SnapMode != CNiCursor::SnapNearestPoint)
  m_Graph.GetCursors().Item(1).YPosition = m_SetyPos.Value;
 //read the acceptable x and y positions that the cursors were moved to
 m_xPos.Value = m_Graph.GetCursors().Item(1).XPosition;
 m_yPos.Value = m_Graph.GetCursors().Item(1).YPosition;
}

Look over this example and let us know if you are still having any trouble.

Thanks

Caroline

National Instruments

 

Message Edited by Support on 07-01-2005 02:08 PM

Thanks,
Caroline Tipton
Data Management Product Manager
National Instruments
0 Kudos
Message 2 of 2
(2,970 Views)