我在客户区画了好多东西,记得有个函数是直接清空的??

解决方案 »

  1.   

    CRect rt;
    GetClientRect(&rt);
    pDC->FillRect(rt,RGB(255,255,255));
      

  2.   

    pDC->PatBlt(left, top, width, height, WHITENESS);
      

  3.   

    VOID Example_Clear(HWND hWnd)
    {
       HDC                hdc;
       PAINTSTRUCT        ps;   // Start a paint session, and create a Graphics object.
       hdc = BeginPaint(hWnd, &ps);
       Graphics graphics(hdc);   // Clear the screen with a teal background.
       graphics.Clear(Color::Teal);...........................here   //End the paint session.
       EndPaint(hWnd, &ps);
    }
      

  4.   

    why not try Invalidate or InvalidateRect
      

  5.   

    哦,不是在客户区,而是整个windows窗口,而却没在CView类里写,不能用有color的刷,我的目的是关闭程序后,画的那些椭圆也消失,但是不影响其他程序的样子,更不想FillRect(rt,RGB(255,255,255));程序如下:Invalidate 和InvalidateRect应该不行吧。
    那个graphics.Clear(Color::Teal);...........................here
    不能通过?
    CRect rect(0,0,100,150);
    int x1 = rand() %rect.right;
    int x2 = rand() %rect.right;
    int y1 = rand() %rect.bottom;
    int y2 = rand() %rect.bottom;
    CClientDC dc(NULL);
    CBrush brush(RGB(rand()% 255,rand()%255,rand()%255));
    CBrush* pOldBrush = dc.SelectObject(&brush);
    dc.Ellipse(min( x1,x2),min( y1,y2 ),max( x1,x2 ), max( y1,y2 ));
    dc.SelectObject(pOldBrush);
    谢谢楼上的,和楼下的。