dc.FillSolidRect(&rect,GetSysColor(COLOR_BTNFACE));
能不能 不要 ?

解决方案 »

  1.   

    可是双缓冲不是这样用的啊
    应该在一个工作线程中完成内存dc中的绘制,在paint函数中的工作只是把内存dc拷贝一下,否则耗时的操作还是在界面线程中执行的,该慢还是慢
      

  2.   

    dc.FillSolidRect(&rect,GetSysColor(COLOR_BTNFACE));
    已经 操作 一次 dc 了
    双缓冲 是 全部 操作 在 memDC 里。
    一次 操作 dc。
      

  3.   

    或者:
    g.FillRectangle(&brush, 0, 0, image.GetWidth(), image.GetHeight());  
      

  4.   

    SolidBrush brush(GetSysColor(COLOR_BTNFACE));
    memgr->FillRectangle(&brush,-rect.Width()/2,-rect.Height()/2,rect.Width(),rect.Height());
    还是不行啊
      

  5.   

    Graphics graphics(dc.m_hDC);
    这是用的dc 吧
      

  6.   


    我有点迷糊了?CDC pdc;
    pdc.CreateCompatibleDC(&dc);
    Graphics graphics(pdc.m_hDC);
    Image image(......);
    graphics.DrawImage(&image,.......);
    dc.bitblt(......);
      

  7.   

    id=SetTimer(1,100,NULL);
    CPaintDC dc(this); 
    CDC pdc;
    pdc.CreateCompatibleDC(&dc);
    Graphics graphics(pdc.m_hDC);
    GetClientRect(&rect);
    graphics.TranslateTransform((REAL)rect.right/2,(REAL)rect.bottom/2);
    graphics.RotateTransform(hudu);
    Image image(L"3.png");
    graphics.DrawImage(&image,-rect.Width()/2,-rect.Height()/2,rect.Width(),rect.Height());
    dc.BitBlt(rect.left,rect.top,rect.Width(),rect.Height(),&pdc,-rect.Width()/2,-rect.Height()/2,SRCCOPY);这样写对不对啊?
      

  8.   

    id=SetTimer(1,100,NULL); 
    在初始化里吧 ?
        CDC pdc;
        pdc.CreateCompatibleDC(&dc);
    pdc 并没有大小? 
    要SelectObject  一个bitmap 吧
      

  9.   

    只能 使用 dc :Graphics graphics(dc.m_hDC);
    不能使用  memDC ?
      

  10.   

    下面是 没旋转时的代码:  CRect rect;
    rect.SetRect(0,0,128,119);
    //
    CDC memDC;
        memDC.CreateCompatibleDC(&dc); HBITMAP hbmp=CreateCompatibleBitmap(dc.m_hDC,rect.Width(),rect.Height());
    memDC.SelectObject(hbmp);    Graphics graphics(memDC.m_hDC);
    //
    SolidBrush brush(GetSysColor(COLOR_BTNFACE));
    graphics.FillRectangle(&brush,0,0,rect.Width(),rect.Height());//
    // rotate
    graphics.RotateTransform(0.0);
    //
    Image image(L"3.png");
    graphics.DrawImage(&image,0,0,rect.Width(),rect.Height());
    HDC hdc = graphics.GetHDC();
    ::BitBlt(dc.m_hDC,0,0,rect.Width(),rect.Height(),hdc,0,0,SRCCOPY);
    graphics.ReleaseHDC(hdc);
      

  11.   

    带蓝边:  CRect rect;
    rect.SetRect(0,0,90,91);
    //
    CDC memDC;
        memDC.CreateCompatibleDC(&dc);
    HBITMAP hbmp=CreateCompatibleBitmap(dc.m_hDC,rect.Width(),rect.Height());
    memDC.SelectObject(hbmp);
    //
        Graphics graphics(memDC.m_hDC);
    // argb
    SolidBrush brush(Color(255,0,0,255));/// 蓝边 !!!!
    graphics.FillRectangle(&brush,0,0,rect.Width(),rect.Height());//
    // move
    // graphics.TranslateTransform((REAL)0.0,0.0);
    // rotate
    // graphics.RotateTransform(0.0);
    //
    Image image(L"3.png");
    graphics.DrawImage(&image,1,1,rect.Width()-2,rect.Height()-2);
    HDC hdc = graphics.GetHDC();
    ::BitBlt(dc.m_hDC,0,0,rect.Width(),rect.Height(),hdc,0,0,SRCCOPY);
    graphics.ReleaseHDC(hdc);
      

  12.   

    之前的代码在win7下好像不闪,在xp下明显有闪烁???????
      

  13.   

    OS win7, vc6 上 运行正常。
    蓝边的 那个(一点宽)  是 为了说明  
    graphics.FillRectangle(&brush,0,0,rect.Width(),rect.Height());//  
    已 作用。
    黑的原因是:
    HBITMAP hbmp=CreateCompatibleBitmap(dc.m_hDC,rect.Width(),rect.Height());
    一定不能 是 memDC !!!
      

  14.   

    这句:
    ::BitBlt(dc.m_hDC,0,0,rect.Width(),rect.Height(),hdc,0,0,SRCCOPY);
    牵涉到 GDI 与 GDI+ 混合 编程的问题。
      

  15.   

    下面是纯 gdi+ :
    CPaintDC dc(this); // device context for painting
    Bitmap CacheImage(90, 90);  
    Graphics CacheGraphics(&CacheImage );  
    // 对 CacheImage 进行描画 
    SolidBrush brush(Color(255,0,0,255));// argb
    CacheGraphics.FillRectangle(&brush,0,0,90,90);//
    Image image(L"3.png");
    CacheGraphics.DrawImage(&image,1,1,88,88);
    // 获得窗口的 Graphics 对象  
    Graphics Graphic(dc.m_hDC);  
    // 将描画好的 CacheImage 画到窗口上  
    Graphic.DrawImage(&CacheImage, 0, 0);
      

  16.   

    应该是画背景的原因吧,不画背景应该就好了。在if(!AfxRegisterClass(&wndcls)) 的前面注释下面的语句
    //wndcls.hbrBackground = (HBRUSH)backGrush.m_hObject;
      

  17.   

    +1 之前也遇到这个问题,后来发现CreateCompatibleBitmap传入的如果是内存DC的话,默认创建的是1*1的单色位图,所以才会出现上面所说的黑块. 如果是视频兼容DC,就会是彩色的. 一不小心很容易掉坑里头.