Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem changing TrackMode from Plot&Cursor (TrackAll) to ZoomXYRectangle

I'm using a CWGraph control from Measurement Studio 6.0 in a C# application.

I want the user to be able to switch between tracking modes on the fly - I use Plot&Cursor mode to allow them to right-click on a point and get more information. But when I switch to ZoomXYRectangle mode, it does not work (it does not allow me to zoom).

Am I missing something? The same functionality works fine on the 3D Graph (switching from TrackAll to TrackZoomPanRotate).

Thanks,
Natalie
0 Kudos
Message 1 of 9
(3,472 Views)
How are you changing the track mode at run-time? Exactly which track mode enumeration mode are you starting with and which one are you switching to? I tried to reproduce this in a test project where I started the application with the TrackMode property set to CWGraphTrackModes.cwGTrackAllEvents. I added a context menu item where in the event handler for the context menu item I changed the TrackMode property to CWGraphTrackModes.cwGTrackZoomRectXY. In my test application I was able to zoom. Could you please post a small test project that reproduces the problem that we can take a look at? Thanks.

- Elton
0 Kudos
Message 2 of 9
(3,472 Views)
I have some radio buttons in a group box that I want to control the track mode.

One button is to turn on the right-clicking capability. In the event handler I have:

axGraph.TrackMode = CWUIControlsLib.CWGraphTrackModes.cwGTrackAllEvents;

The other radio button is to turn on the zooming capability. In the event handler I have:

axGraph.TrackMode = CWUIControlsLib.CWGraphTrackModes.cwGTrackZoomRectXY;

Inexplicably, this works fine if I change cwGTrackZoomRectXY to cwGTrackPanPlotAreaXY in the above line. The plot/cursor events and the panning functionality work. The zooming doesn't.

It'll take me a few minutes to throw together a simple example. Is a C# project okay?
0 Kudos
Message 3 of 9
(3,472 Views)
C# project is great - I have both Visual Studio .NET and the release candidate for Visual Studio .NET 2003. Thanks.

- Elton
0 Kudos
Message 4 of 9
(3,472 Views)
Of course my "simple" version of the app does not demonstrate this problem. I must be doing something funky in my real app. Do you know of any graph settings that would override the Zoom events?

What happens in my real app is when the plot is "fresh" I can switch to Zoom mode and it works. If I switch back to TrackAll mode, Zoom never works again (the zoom rectangle doesn't draw in response to Mouse Down).

Just for fun I'm attaching the simple app that does NOT demonstrate this problem. Thanks for your help so far. I'll be back if I find any more clues.
0 Kudos
Message 5 of 9
(3,472 Views)
I spoke too soon. In my app, I bring up a context menu on right click. This appears to be causing the problem.

To reproduce, run the attached Windows Forms app.
1. Try changing the track modes and verify that they all work.
2. Change the track mode back to Plot and Cursor. Right click on a point to bring up information about that point.
3. Switch to Zoom mode and see that it no longer works.

Any ideas why this would be causing problems?

Thanks!
Natalie
0 Kudos
Message 6 of 9
(3,472 Views)
This is pretty strange ... I played around with the project for a while and there seems to be something about bringing up the context menu that throws something off. If you comment out the line of code that shows the context menu, the problem doesn't reproduce anymore. Also, if it's not working after you switch to zoom mode, you can right-click anywhere on the graph and then try to zoom, and it'll work.

Off the top of my head I can't think of a good reason why this is happening. Since it will work again if you right-click anywhere on the graph, you could hack a workaround by sending a message to the AxHost that's hosting the ActiveX control to make it think that it received a right-click. It's a total hack to fix it, but it does work. Here's some
sample code that shows how to do this:

// Place this code somewhere in the form class:

[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern int SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);

private const int WM_RBUTTONUP = 0x0205;
private const int MK_RBUTTON = 0x0002;

private static int MAKELPARAM(int low, int high)
{
return ((low & 0xffff) | ((high & 0xffff) << 16));
}

// Change the CheckedChanged event handler for the zoom radio button so that
// the message is sent when the track mode is changed.
private void zoom_CheckedChanged(object sender, System.EventArgs e)
{
if (zoom.Checked)
{
axGraph.TrackMode = CWUIControlsLib.CWGraphTrackModes.cwGTrackZoomRectXY;
SendMessage(axGraph.Handle, WM_RBUTTONUP, MK_RBUTTON, MAKELPARAM(1, 1));
}
}

- Elton
0 Kudos
Message 7 of 9
(3,472 Views)
Thanks very much for the hack... I put it in my code and now it seems to work perfectly. I really appreciate the quick response.

Natalie
0 Kudos
Message 8 of 9
(3,472 Views)
One more note about this - I tried to reproduce this in VB6 and was unable to get it to reproduce. This seems like a problem with the Windows Forms interop control for the graph, so the code above is probably the easiest way to work around this.

- Elton
0 Kudos
Message 9 of 9
(3,472 Views)