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