Mouse clicks to select range on graph

Hello all, I'm currently working with this program that can generate a graph from given data. The graph contains a series of peaks in it and the program is designed to pick out the maximum peak in the graph and perform calculations with it. My problem is that I need to do this calculation for every peak in the graph (i.e. - all the maximums in the graph), and some graphs contain more than 5 peaks, which I currently have to calculate by hand (not fun). The graph is just a generated image (from the click of a button) in the program, meaning when I close the program there is no .bmp, .jpg, etc file outputted.

What I would like to do is run the program as normal (having it run the calculation on the maximum peak), and then allow the user to click a button that would then allow the user to select a range on that generated graph, hopefully just by clicking with the left mouse button twice. This way the user can click on both sides of any peak on the graph and then the program can find the maximum within that range, and thus running the calculation on that peak instead of the absolute maximum peak. The main problem I'm having is being able to write code for the mouse clicking twice to select a range on the image.

Does this way sound reasonable? And if so, could anyone point me in the right direction for information on how to accomplish such a task? Thanks.
The general way that selecting graphic objects or an area of a window is using the rubber banding technique.

The user holds the lef mouse button down and drags the mouse with the left button held down.
Once the user has completed the selection, then he/she stops moving the mouse and releases the
left button.
While the mouse moving is in progress, the application usually provides some visual feedback by
drawing a rectangle from the original left click position to the current mouse position.
Because this rectangle expands/shrinks as the mouse is move that is why you get the term rubber-banding.

In order to do this, you will need to utilize the following window messages:

1. WM_LBUTTONDOWN
2. WM_MOUSEMOVE
3. WM_LBUTTONUP


Topic archived. No new replies allowed.