我用bitblt在屏幕上显示了一幅图,完了怎么把它删了,用什么函数?
谢谢

解决方案 »

  1.   

    选择一个空位图,然后Bitblt。
      

  2.   

    假设你的绘图设备是pDC,客户区是rc。CBitmap* pBitmap = NULL;
    CDC memDC;
    memDC.CreateCompatibleDC(pDC);
    memDC.SelectObject(pBitmap);
    pDC->Bitblt(0,0, rc.Width(),rc.Height(), &memDC, 0, 0, SRCCOPY);
      

  3.   

    不好意思我的是SDK的程序,要是不用MFC应该怎么做?
      

  4.   

    假设你的绘图设备是hDC, 客户区是rcHBITMAP hBitmap = NULL;
    HDC hMem = ::CreateCompatibleDC(hDC);
    ::SelectObject(hBitmap);
    ::Bitblt(hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,hMem, 0, 0, SRCCOPY);
      

  5.   

    不行啊,没擦掉,把主要代码贴过来。其中hbitmap是通过LoadImage()创建的。     POINT pdest;
        ::GetCursorPos(&pdest);
        POINT psrc;
        psrc.x = psrc.y = 0;
        SIZE size;
        size.cx = width;
        size.cy = height;
        HDC hdcdest = ::GetDC(NULL);
        HDC hdcsrc = CreateCompatibleDC(hdcdest);
        ::SelectObject(hdcsrc, hbitmap);
        ::BitBlt(hdcdest, pdest.x, pdest.y, width, height, hdcsrc, 0, 0, SRCCOPY);
        ::Sleep(200);    HBITMAP hbitmap2 = NULL; 
        ::SelectObject(hdcdest, hbitmap2); 
        ::BitBlt(hdcdest, pdest.x, pdest.y, width, height, hdcsrc, 0, 0, SRCCOPY);    ::DeleteDC(hdcsrc);
        ::ReleaseDC(NULL, hdcdest);能不能帮我再看看,谢谢!
      

  6.   

        POINT pdest; 
        ::GetCursorPos(&pdest); 
        POINT psrc; 
        psrc.x = psrc.y = 0; 
        SIZE size; 
        size.cx = width; 
        size.cy = height; 
        HDC hdcdest = ::GetDC(NULL); 
        HDC hdcsrc = CreateCompatibleDC(hdcdest); 
        ::SelectObject(hdcsrc, hbitmap); 
        ::BitBlt(hdcdest, pdest.x, pdest.y, width, height, hdcsrc, 0, 0, SRCCOPY); 
        ::Sleep(200);     //你是要删除上一次绘图的痕迹吧
        //加入下面一句,最后一个参数如果用BLACKNESS表示用黑色,WHITENESS表示白色
        ::BitBlt(hdcdest, pdest.x, pdest.y, width, height, NULL, 0, 0, BLACKNESS);    HBITMAP hbitmap2 = NULL; 
        ::SelectObject(hdcdest, hbitmap2); 
        ::BitBlt(hdcdest, pdest.x, pdest.y, width, height, hdcsrc, 0, 0, SRCCOPY);     ::DeleteDC(hdcsrc); 
        ::ReleaseDC(NULL, hdcdest);
    我想你是要清除上一次绘图的痕迹,不然绘了又清除,没什么意义啊.
      

  7.   

    改了一下,应该能行吧:
     POINT pdest; 
        ::GetCursorPos(&pdest); 
        POINT psrc; 
        psrc.x = psrc.y = 0; 
        SIZE size; 
        size.cx = width; 
        size.cy = height; 
        HDC hdcdest = ::GetDC(NULL); 
        HDC hdcsrc = CreateCompatibleDC(hdcdest); 
        ::SelectObject(hdcsrc, hbitmap); 
        ::BitBlt(hdcdest, pdest.x, pdest.y, width, height, hdcsrc, 0, 0, SRCCOPY); 
        ::Sleep(200);     //HBITMAP hbitmap2 = NULL; 
      //  ::SelectObject(hdcdest, hbitmap2); 
      //  ::BitBlt(hdcdest, pdest.x, pdest.y, width, height, hdcsrc, 0, 0, SRCCOPY); 

     ::BitBlt(hdcdest, pdest.x, pdest.y, bm.bmWidth, bm.bmHeight, hdcsrc, 0,0,WHITENESS);
        ::DeleteDC(hdcsrc); 
        ::ReleaseDC(NULL, hdcdest); 
      

  8.   


    还是用这个吧
    最后再发送一条 UpdateWindow 消息来通知桌面更新!
    你也够狠的,直接在桌面画图,如果你照上面几楼说的办,那你看看你的桌面背景会变成什么样!
    要不你就建立一个全局的内存 DC,每次画图后就把画好的内容复制一份到这个 DC 上!
    如果需要恢复桌面内容(或者说上一次画的内容),把 DC 上的内容重新复制回去就行了。
      

  9.   

    InvalidateRect 就可以搞定!
      

  10.   

    画图?在哪里话,onpaint?不是的话直接invalidate,是的话在onpaint里面不画图,然后再invalidate
      

  11.   

    InvalidateRect就可以了。或者干脆Invalidate整个窗口。