LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I add a cursor to a graph programmatically?

Is there any way to add a cursor to a graph dynamically? I'm wanting to generate a new cursor when a user clicks on an empty part of a graph.
0 Kudos
Message 1 of 4
(3,589 Views)
Yes, just call CWGraph.Cursors.Add. Then, you can set the position and properties of the cursor after that.

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 2 of 4
(3,589 Views)
Oops, sorry, disregard my previous post. I answered the question for the ActiveX Graph. For the CVI Graph, just use SetCtrlAttribute to increase the number of cursors attribute. Then you can use SetCursorAttribute to setup the cursor.

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 3 of 4
(3,589 Views)
Hi,

You can use following statements for adding cursor to your graph programatically:

int count;
GetCtrlAttribute(panel, graph, ATTR_NUM_CURSORS, &count);
count++;
SetCtrlAttribute(panel, graph, ATTR_NUM_CURSORS, count);

Now, here GetCtrlAttribute will give you how many cursors your graph have currently. You can increment the count and add cursor using SetCtrlAttribute with attribute as ATTR_NUM_CURSORS.

You can add above lines of code in the callback.

Regards,
Niranjan
0 Kudos
Message 4 of 4
(3,589 Views)