解决方案 »

  1.   

    窗口创建的时候会重绘一次,这时候也画一次背景。具体的消息忘记了,用spy++抓下看看。
    另外,窗口创建完毕后调用UpdateWindow可能有效果。Windows GDI坑比较多,在不同系统上表现也不一致,还是多试试看吧。
      

  2.   

    没有看到内存兼容DC,CDCHandle是什么?
    双缓冲绘图,HDC hMemDC, hBITMAP hMemBitmap;
      

  3.   

    我这个是 WTL, 用的GDI + ...CDCHandle 是WTL 里面的CDC 的一个类
      

  4.   

    感觉gdi + 就是个坑...真没gdi好用,我用gdi 的方式 也会闪,但是好多了..
      

  5.   

    void DoPaint(CDCHandle  dc)
    {
    T *  t = static_cast<T *>(this); ATLASSERT(m_pBkgndImage->get());
    CRect rc;
    CMemDC myMemDC(dc, this);
    t->GetWindowRect(&rc); CGdiPlusBitmapHelper helpr (rc.Width(), rc.Height());
    helpr.StretchBlt(m_pBkgndImage->get(), 0, 0, 0,0,rc.Width(),rc.Height()); //画需要镂空的三角 
    Color color(255,255,0,0);
    helpr.DrawTriang(TRIANG_PIX, color);
    helpr.Profile(rc, TRIANG_PIX, Color(255,0,0,0), 1); DrawTitle(t, helpr);//画标题 Graphics g(&myMemDC.GetDC());
    g.SetSmoothingMode(SmoothingModeAntiAlias);
    g.DrawImage(helpr.get(), 0 , 0 , rc.Width(), rc.Height());
    }
      

  6.   


    我有些怀疑 Graphics::DrawImage 的速度... 背景贴图的 程序我做过,用的GDI双缓冲,没闪烁过,怎么用了GDI+ 一个劲儿的闪
      

  7.   

    我这个是 WTL, 用的GDI + ...CDCHandle 是WTL 里面的CDC 的一个类
    GDI+和GDI混合使用:
    不管用的MFC还是WTL,标准的WINDOWS API都是支持的RECT rc;
    GetWindowRect(m_hWnd, &rc);
    int nWidth=rc.right-rc.left;
    int nHeight=rc.bottom-rc.top;
    HDC hMemDC=CreateCompatibleDC(dc.m_hDC);
    HBITMAP hMemBitmap=CreateCompatibleBitmap(dc.m_hDC, nWidth, nHeight);
    HBITMAP hOldBitmap=(HBITMAP)SelectObject(hMemDC, hMemBitmap);
    //在内存DC画图
    Graphics g(hMemDC);
    g.DrawImage(&image, 0, 0, nWidth, nHeight);
    //贴到窗口DC上
    BitBlt(dc.m_hDC, 0, 0, nWidth, nHeight, hMemDC, 0, 0, SRCCOPY);
    SelectObject(hMemDC, hOldBitmap);
    //释放GDI资源
    DeleteDC(hMemDC);
    DeleteObject(hMemBitmap);DrawImage效率的确不咋的
      

  8.   

    我这个是 WTL, 用的GDI + ...CDCHandle 是WTL 里面的CDC 的一个类
    GDI+和GDI混合使用:
    不管用的MFC还是WTL,标准的WINDOWS API都是支持的RECT rc;
    GetWindowRect(m_hWnd, &rc);
    int nWidth=rc.right-rc.left;
    int nHeight=rc.bottom-rc.top;
    HDC hMemDC=CreateCompatibleDC(dc.m_hDC);
    HBITMAP hMemBitmap=CreateCompatibleBitmap(dc.m_hDC, nWidth, nHeight);
    HBITMAP hOldBitmap=(HBITMAP)SelectObject(hMemDC, hMemBitmap);
    //在内存DC画图
    Graphics g(hMemDC);
    g.DrawImage(&image, 0, 0, nWidth, nHeight);
    //贴到窗口DC上
    BitBlt(dc.m_hDC, 0, 0, nWidth, nHeight, hMemDC, 0, 0, SRCCOPY);
    SelectObject(hMemDC, hOldBitmap);
    //释放GDI资源
    DeleteDC(hMemDC);
    DeleteObject(hMemBitmap);DrawImage效率的确不咋的
     是的....我全部改成用 GDI 的方式了。。 闪烁消失了....
      

  9.   

    我这个是 WTL, 用的GDI + ...CDCHandle 是WTL 里面的CDC 的一个类
    GDI+和GDI混合使用:
    不管用的MFC还是WTL,标准的WINDOWS API都是支持的RECT rc;
    GetWindowRect(m_hWnd, &rc);
    int nWidth=rc.right-rc.left;
    int nHeight=rc.bottom-rc.top;
    HDC hMemDC=CreateCompatibleDC(dc.m_hDC);
    HBITMAP hMemBitmap=CreateCompatibleBitmap(dc.m_hDC, nWidth, nHeight);
    HBITMAP hOldBitmap=(HBITMAP)SelectObject(hMemDC, hMemBitmap);
    //在内存DC画图
    Graphics g(hMemDC);
    g.DrawImage(&image, 0, 0, nWidth, nHeight);
    //贴到窗口DC上
    BitBlt(dc.m_hDC, 0, 0, nWidth, nHeight, hMemDC, 0, 0, SRCCOPY);
    SelectObject(hMemDC, hOldBitmap);
    //释放GDI资源
    DeleteDC(hMemDC);
    DeleteObject(hMemBitmap);DrawImage效率的确不咋的
     是的....我全部改成用 GDI 的方式了。。 闪烁消失了....
    姜还是老的辣!