Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Need X and Y coordinates while zooming

Hi,
I'm using MStudio 6.0 C++ (for now) and I need to know the X and Y position in graph coords (not pixels) all the time, even while zooming. I can monitor mouse moves but that only provides screen coords. I can upgrade to 7.0 if that would help but using C# or managed C++ is out of the question for us here. It would be ideal if there was a simple function to convert screen coords to graph coords and vice versa.

Thanks, Bob
0 Kudos
Message 1 of 4
(3,606 Views)
Hello Bob

The CWGraph ActiveX control does not expose any API for mapping graph coordinates to screen coordinates and vice versa. To be able to get the screen coordinates, you would need to get the control's HWND, get the controls image bitmap data and manually try to parse through it. You might set the Graphs plot area with a special bitmap using the PlotAreaImage property of the graph so you could locate where the plot area starts and ends. But basically, you would need to perform some processing on the controls image to extract the coordinate information.

If you can describe what the overall goal for the application is, perhaps I could be of more help.

Thanks

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 2 of 4
(3,606 Views)
In this particular application, the user needs a display of the current XY values for the current mouse position. We also need to show the XY values while dragging the zoom rectangle.

I worked around the missing feature by adding overrides for the following functions:
OnPlotAreaMouseDown
OnPlotAreaMouseUp
OnPlotAreaMouseMove
OnMouseDown
OnMouseUp
OnMouseMove

I set the track mode to TrackPlotAreaEvents. The plot area versions give me the graph XY coordinates and the regular ones give me screen coordinates. Since both sets get called, I have all the information I need do my own zooming, draw rubber-band, etc., and still get the current mouse position in graph units.

One interesting bug/feature I found - in the OnPlotAreaMouseUp callba
ck, it gets called with the Button value set to 0, which doesn't correspond to any of the defined button enum values. I didn't investigate it further - maybe it's because both callback handlers are registered.
0 Kudos
Message 3 of 4
(3,606 Views)
That sounds like a great workaround.

I can reproduce the same thing with that particular callback. It seems to be only the OnPlotAreaMouseUp event. It also seems to happen when it is the only callback registered. I have reported this problem to R&D so we can investigate this further

Thanks

Bilal
Bilal Durrani
NI
0 Kudos
Message 4 of 4
(3,606 Views)