From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there any easy way to convert pixel (x and y) point to coordinate position?

Here is the situation: I am trying to control the mouse movement by just clicking at the targetted coordinate (not click at the mouse and drag to the targetted coordinate). Somehow, I can not detect the CursorMouseDown event. I can only detect the MouseDown event which passed the mouse position in terms of pixels. I need to convert these pixels to the coordinate in the plot and I can use the SetPosition command. Is there any easy way to do?
0 Kudos
Message 1 of 3
(2,999 Views)
There isn't a built in way to convert coordinates. You would need to get the Plot area size (PlotAreaImage.Height and Width) and the graph control size, and then use you axis range to convert the pixels values to XY coordinates. You can get the CursorMouseDown event though if your graph in in track mode "Plot and Cursor Events".

Best Regards,

Chris Matthews
National Instruments
Message 2 of 3
(2,999 Views)
Chris, I'm not sure that your answer is correct? I don't think that you can assume that the plot area is centered within its control.
0 Kudos
Message 3 of 3
(2,999 Views)