UPDATE: Thanks for IInspectable's reply. I have edited my problem.
I am writing a dialog-based application which has a static control.
The app draws a line according to the points captured by OnLButtonDown()
and OnLButtonUp()
.
I create a class CCanvasStatic
derived from CStatic
and the static control variable is of the type CCanvasStatic
. I add OnPaint()
, OnLButtonDown()
and OnLButtonUp()
to the class CCanvasStatic
.
My OnLButtonDown()
and OnLButtonUp()
are like these:
void CCanvasStatic::OnLButtonDown(UINT nFlags, CPoint point)
{
SetCapture ();
if (this == GetCapture ())
(*m_pBGDlg->m_Shape).m_ptStart = point;
CStatic::OnLButtonDown(nFlags, point);
}
void CCanvasStatic::OnLButtonUp(UINT nFlags, CPoint point)
{
if (some expression)
{
(*m_pBGDlg->m_Shape).m_ptEnd = point;
Invalidate ();
UpdateWindow ();
}
ReleaseCapture ();
CStatic::OnLButtonUp(nFlags, point);
}
I expect Invalidate()
to erase previous drawing so that each time I draw a new line, all lines I have drawn are redrawn (I want this because I use an array to record all lines and use a loop in OnPaint()
to deal with the issue of repaint).
But Invalidate()
does not do what I expect. How can erase previous drawing? Thank you!