CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: redraw

Threaded View

  1. #1
    Join Date
    May 2011
    Posts
    23

    redraw

    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);
    }
    Last edited by Marc G; December 19th, 2011 at 03:38 PM. Reason: Added code tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured