To understand the mfc dialog, onpaint better, after reading some online notes, made a little project. This draws a Horz. axis with a red color curve above it. What I can not figure how to do, is to redraw the whole thing multiple times with each time the whole plot moves. Like erase/redraw thing. don't know how to erase and redraw.
Code:void MyDraw::OnPaint() { CPaintDC dc(this); DrawC(dc); } void MyDraw::DrawC(CDC& dc) { CRect rect; GetClientRect(rect); HDC hdc = dc.GetSafeHdc(); CPen aPen, dkpen, redPen; aPen.CreatePen(PS_SOLID, 2, RGB(255, 225, 225)); dkpen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0)); redPen.CreatePen(PS_SOLID, 1, RGB(255, 0, 0)); CPen* pOldPen = dc.SelectObject(&aPen); CPen* gOldPen = dc.SelectObject(&dkpen); dc.MoveTo(10,250); dc.LineTo(220,250); dc.MoveTo(220,250); dc.LineTo(215,255); dc.MoveTo(220,250); dc.LineTo(215,245); gOldPen = dc.SelectObject(&redPen); dc.MoveTo(10, 250); dc.LineTo(100, 220); dc.LineTo(150, 200); dc.LineTo(190, 160); dc.LineTo(195, 130); }




Reply With Quote