I need help with making a certain MFC program. I need to make a program that will draw a line in the following way: the user chooses the starting point by left clicking, and the final point by left clicking the second time, after which the points are connected and the line is drawn. I've managed to get the coordinates of the first one with this:

```
void CsemView::OnLButtonDown(UINT nFlags, CPoint point)
{
    CsemDoc* pDoc= GetDocument();
    // TODO: Add your message handler code here and/or call default 
    pDoc->a_pos=point;
    Invalidate();
    CView::OnLButtonDown(nFlags, point);
}

```

The problem is, i don't know how to get the coordinates of the second one with the second left click. I've managed to do it by using the on double left click function( and putting pDoc->b\_pos=point; in it), but that's not really what I was supposed to do. (I was putting in the coordinates of the first one into MoveTo and the second one into LineTo). I would appreciate if someone could help me (I'm suspecting there's perhaps a different, simpler way of doing this).
Thanks in advance.
['https://Stackoverflow.com/questions/14297940', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1973086/']
If you want to get two results from a same event, you have to keep a state variable to track wht click is it.

On other words, your `CsemDoc` should have an `a_pos` and `b_pos` members, and `CsemView` a `bool is_b`, initialized as false.

The `OnLButtonDow` method should: be something like

```
if(!is_b)
{ set the a_pos; is_b = true; }
else
{ set the b_pos; is_b = false; invalidate the draw; }

```
You can push the mouse co-ordinates on each LButtonDown to a vector and draw the lines between P[i] and P[i+1] and upon a RButtonDown you can stop recording of the points after that and no more extra lines will be drawn. Have a separate button like any drawing toolbox to start the line drawing so that any LButtonDown events after that will be pushed to the vector.

Hope this helps!