You will have to remember all the points and then every time ondraw is being called it will use the stored values to draw lines.
You can use vector to store all your clicked points. It would be best practice if you just use vector to store your data
void CserializationTestView::OnDraw(CDC* pDC)
{
CappDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
for(std::vector<CCoords>::iterator it=list.begin();it!=list.end();++it)
{
pDC->MoveTo(it->start);
pDC->LineTo(it->End);
}
}
void CserializationTestView::OnLButtonUp(UINT nFlags, CPoint point)
{
list[list.size()-1].End=point;
Invalidate();
}
void CserializationTestView::OnLButtonDown(UINT nFlags, CPoint point)
{
CCoords nlist;
nlist.start=point;
list.push_back(nlist);
}
class CCoords
{
public:
CPoint start;
CPoint End;
};