Example #1
0
void SItemPanel::OnRedraw(const CRect &rc)
{
    if(m_pFrmHost->IsUpdateLocked()) return;

    CRect rcItem=GetItemRect();
    if(!rcItem.IsRectNull() && m_pFrmHost->IsVisible(TRUE))
    {
        if(m_pItemContainer->IsItemRedrawDelay())
        {
            CRect rc2(rc);
            rc2.OffsetRect(rcItem.TopLeft());
            rc2.IntersectRect(rc2,rcItem);
            CRect rcHostClient = m_pFrmHost->GetClientRect();
            rc2.IntersectRect(rc2,rcHostClient);
            m_pFrmHost->InvalidateRect(rc2);
        }else
        {
            IRenderTarget *pRT=OnGetRenderTarget(rc,OLEDC_PAINTBKGND);
            CAutoRefPtr<IRegion> rgn;
            GETRENDERFACTORY->CreateRegion(&rgn);
            rgn->CombineRect(&rc,RGN_COPY);
            RedrawRegion(pRT,rgn);
            OnReleaseRenderTarget(pRT,rc,OLEDC_PAINTBKGND);
        }
    }
}
Example #2
0
HRESULT RichEditOleBase::Draw(
    DWORD dwDrawAspect, 
    LONG lindex,  
    void *pvAspect, 
    DVTARGETDEVICE *ptd, 
    HDC hdcTargetDev,
    HDC hdcDraw, 
    LPCRECTL lprcBounds,
    LPCRECTL lprcWBounds,
    BOOL ( STDMETHODCALLTYPE *pfnContinue )(ULONG_PTR dwContinue), 
    ULONG_PTR dwContinue)
{
    InvertBorder(hdcDraw, (RECT*)lprcBounds);

    m_rcObj = (RECT*)lprcBounds;
    m_rcObj.InflateRect(-1,-1,-1,-1); // 四周留一个像素给RichEdit画反色框
    m_oleWindow.SetOleWindowRect(m_rcObj);

    CAutoRefPtr<IRegion> rgn;
    GETRENDERFACTORY->CreateRegion(&rgn);
    rgn->CombineRect((RECT*)lprcBounds,RGN_AND);

    CAutoRefPtr<IRenderTarget> pRT;
    GETRENDERFACTORY->CreateRenderTarget(&pRT, m_rcObj.Width(), m_rcObj.Height());

    // 画背景
    HDC hdc = pRT->GetDC(0);
    ::BitBlt(hdc, 0, 0, m_rcObj.Width(), m_rcObj.Height(),
        hdcDraw, m_rcObj.left, m_rcObj.top, 
        SRCCOPY);

    // 画richedit
    m_oleWindow.RedrawRegion(pRT, rgn);

    // 贴到目标DC
    ::BitBlt(hdcDraw, m_rcObj.left, m_rcObj.top, m_rcObj.Width(), m_rcObj.Height(),
        hdc, 0, 0, 
        SRCCOPY);

    pRT->ReleaseDC(hdc);

    return S_OK;
}