Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Anybody implement graph zoom with mouse wheel?

I need to implement a zoom feature with the middle mouse wheel (like Google Maps, Google Earth, etc) on a CNiGraph.  So if the mouse cursor is over the graph, and the user scrolls the mouse wheel forward, the graph zooms out; if he scrolls the wheel backward the graph zooms in.  My CNiGraph already supports the lasso zoom, and half-scale zoom in / double-scale zoom out with toolbar buttons and hot keys, but the customer (boss) always wants more!!!  I'm using Measurement Studio 8, Visual C++ in Visual Studio 2005.  If you have any hints, links, or code that would help, I'd appreciate seeing it!  Thanks!
0 Kudos
Message 1 of 2
(8,010 Views)
Hi Andy,

CNiGraph does not have the feature built in to listen for mouse wheel events. From the help:
void OnMouseDown( short Button, short Shift, long x, long y )
void OnMouseMove( short Button, short Shift, long x, long y )
void OnMouseUp( short Button, short Shift, long x, long y )

Your best bet would be to check MSDN to see if managed C++ (.NET), or unmanaged C++ (MFC) have this event. If so, you could add the listener and check the position of the mouse cursor when the event fires using
GetPlotAreaBounds. If it is over the plot, you could then manually zoom the graph by programmatically setting the min and max of the axes like this post shows.

Regards,
0 Kudos
Message 2 of 2
(7,991 Views)