Ejemplo n.º 1
0
    SCaret::SCaret(SWND swnd,HBITMAP hBmp,int nWidth,int nHeight)
        :m_owner(swnd)
    {
        CAutoRefPtr<IRenderTarget> pRT;
        GETRENDERFACTORY->CreateRenderTarget(&pRT,nWidth,nHeight);
        m_bmpCaret = (IBitmap*) pRT->GetCurrentObject(OT_BITMAP);
        if(hBmp)
        {
            //以拉伸方式创建一个插入符位图
            HDC hdc=pRT->GetDC(0);
            HDC hdc2=CreateCompatibleDC(hdc);
            SelectObject(hdc2,hBmp);

            BITMAP bm;
            GetObject(hBmp,sizeof(bm),&bm);
            StretchBlt(hdc,0,0,nWidth,nHeight,hdc2,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
            DeleteDC(hdc2);
            pRT->ReleaseDC(hdc);
        }
        else
        {
            //创建一个黑色插入符的位图
            pRT->FillSolidRect(&CRect(0,0,nWidth,nHeight),RGBA(0,0,0,0xFF));
        }
    }
Ejemplo n.º 2
0
int SHotKeyCtrl::OnCreate( LPVOID )
{
    int nRet=__super::OnCreate(NULL);
    if(nRet!=0) return nRet;
    
    CAutoRefPtr<IRenderTarget> pRT;
    GETRENDERFACTORY->CreateRenderTarget(&pRT,0,0);
    BeforePaintEx(pRT);
    m_curFont=(IFont*)pRT->GetCurrentObject(OT_FONT);
    return 0;
}