Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

PlotMouseDown event

I'm having trouble capturing the PlotMouseDown event for a 2D Graph. I have the graph set to "Enabled." My EventSink entry looks like this:

ON_EVENT(CUiResultsDlgCapChart, IDC_RESULTS_CAP_CWGRAPH1, 1 /* PlotMouseDown */, OnPlotMouseDown, VTS_PI2 VTS_PI2 VTS_PVARIANT VTS_PVARIANT VTS_PI2 VTS_PI4)

My OnPlotMouseDown prototype looks like this:

afx_msg void OnPlotMouseDown(short FAR* Button,
short FAR* Shift,
VARIANT FAR* XData,
VARIANT FAR* YData,
short FAR* PlotIndex,
long FAR* PointIndex);

I set the track mode to CNiGraph::TrackAllEvents. When I click on the plot, nothing happens. If I change the track mode to TrackPanPlotAreaXY, I am able to pan the plot as expected. What am I missing? Thanks.

Mark
0 Kudos
Message 1 of 5
(3,591 Views)
If you've sunk the event and your track mode is CNiGraph::TrackAllEvents, it should be working. Note that in order to get the PlotMouseDown event, you have to click directly on the plot line, not just anywhere in the plot area. If you want to handle the event for anywhere in the plot area, handle the PlotAreaMouseDown event.

- Elton
Message 2 of 5
(3,591 Views)
I changed to the PlotAreaMouseDown event, and that doesn't work either.

ON_EVENT(CUiResultsDlgCapChart, IDC_RESULTS_CAP_CWGRAPH1, 2 /* PlotAreaMouseDown */, OnPlotAreaMouseDown, VTS_PI2 VTS_PI2 VTS_PVARIANT VTS_PVARIANT)

I have done the same thing for a 3D graph in the same program, and I had no problems with that. Do you know what the 3rd parameter on the EventSink entry represents? If anyone else has any ideas on something that is easy to overlook, please let me know. Thanks.

Mark
0 Kudos
Message 3 of 5
(3,591 Views)
Please try the following steps and see what the results are:


  1. Create a new project via the NI Measurement Studio AppWizard.

  2. In Step 1, select "Measurement MFC Application."

  3. In Step 2, make sure Common and User Interface are checked.

  4. On the next dialog, click Finish.

  5. Remove the TODO label from the dialog and add a CNiGraph.

  6. Right-click on the graph and click "Properties". Go to the Graph tab and set the track mode to "Plot Area Events".

  7. Right-click on the graph and click "Events...". Select PlotAreaMouseDown and click "Add Handler". Click OK.

  8. Add a MessageBox(_T("PlotAreaMouseDown")) call to the event handler that you just added.

  9. Run the applica
    tion and click anywhere in the plot area.



On my machine, I get the message box when I click anywhere in the plot area. Also, the third parameter of the event is the X position of where the mouse click occurred. Please try the steps above and post what your results were. Thanks.

- Elton
0 Kudos
Message 4 of 5
(3,591 Views)
I followed your directions, and it worked fine. I then removed the graph object from my dialog and started from scratch, and it works now. I'm not sure what I did to mess it up the first time. Thanks for your help.

Mark
0 Kudos
Message 5 of 5
(3,591 Views)