Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Change mouse cursor over graph cursor.

Is there a way to change the mouse cursor as it moves over graph cursors when using trackmode TrackDragCursor? To indicate that you can position the cursor.
0 Kudos
Message 1 of 7
(6,360 Views)
You could accomplish this with the graph's CursorMouseMove event. For example, create a new project with the NI Measurement Studio AppWizard and follow these steps:


  1. Add a graph to the dialog. Right-click on the graph in the dialog editor, click "Class Wizard ...", click the Member Variables tab and add a member variable for the graph called m_graph. Click OK.

  2. Right-click on the graph in the dialog editor and click on "Events ...". Add an event handler for CursorMouseMove called OnCursorMouseMove and add an event handler for PlotAreaMouseMove called OnPlotAreaMouseMove. Click OK.

  3. Go to the header file for your dialog class and add this to the bottom of the class declaration:

    private:
    bool m_cursorChanged;

    HCURSOR m_defaultCursor;
    HCURSOR m_crossCursor;

  4. Go to the source file for your dialog class and add this to the end of the
    OnInitDialog method:

    m_graph.TrackMode = CNiGraph::TrackAllEvents;
    m_graph.Cursors.Add();

    m_cursorChanged = false;
    m_defaultCursor = ::LoadCursor(NULL, IDC_ARROW);
    m_crossCursor = ::LoadCursor(NULL, IDC_CROSS);

  5. Add this to your CursorMouseMove event hander:

    if (!m_cursorChanged)
    {
    ::SetCursor(m_crossCursor);
    m_cursorChanged = false;
    }

  6. Add this to your PlotAreaMouseMove event handler:

    if (m_cursorChanged)
    {
    ::SetCursor(m_defaultCursor);
    m_cursorChanged = true;
    }

  7. Run the application. You should see that the mouse cursor changes to a cross when you mouse over the cursor.



Hope this helps.

- Elton
0 Kudos
Message 2 of 7
(6,361 Views)
Greetings,

To add to Elton's detailed answer, just make sure that the Graph's Windowless property is NOT checked (should be set to false). Otherwise, you won't see the cursor changing since the Graph won't be receiving any windows events.

Good luck,
Azucena
0 Kudos
Message 3 of 7
(6,358 Views)
Is there a way to do this with m_graph.TrackMode = CNiGraph::TrackDragCursor? Or do I need to implement
dragging with TrackAllEvents?
0 Kudos
Message 4 of 7
(6,357 Views)
I haven't tested this, but I think TrackAllEvents is the only way that you're going to get both the plot area events and the cursor events that you need for this.

- Elton
0 Kudos
Message 5 of 7
(6,358 Views)
how to do this in Labview, not the labwindows?
thank you

Jack
0 Kudos
Message 6 of 7
(6,138 Views)
jack,
In LabVIEW 8.20, when you move your mouse cursor over your graph cursor, the mouse cursor changes automatically.
 
Chris C
0 Kudos
Message 7 of 7
(6,117 Views)