首页 > 代码库 > ActiveX显示图片

ActiveX显示图片

直接看代码:

// IPlayCtlpublic:    HRESULT OnDraw(ATL_DRAWINFO& di)    {        RECT& rc = *(RECT*)di.prcBounds;        /*        Rectangle(di.hdcDraw, rc.left, rc.top, rc.right, rc.bottom);        SetTextAlign(di.hdcDraw, TA_CENTER|TA_BASELINE);        LPCTSTR pszText = _T("ATL 3.0 : PlayCtl");        TextOut(di.hdcDraw,             (rc.left + rc.right) / 2,             (rc.top + rc.bottom) / 2,             pszText,             lstrlen(pszText));        */        HDC hdc=di.hdcDraw;        m_hBitmap= //(HBITMAP)LoadBitmap (NULL, "D:\\test.bmp") ;             (HBITMAP)::LoadImage(NULL,"D:\\test.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);          HDC hdcMem=CreateCompatibleDC(hdc);        SelectObject(hdcMem, m_hBitmap);        BitBlt(hdc,0,0,IMAGE_WIDTH,IMAGE_HEIGHT,hdcMem,0,0,SRCCOPY);        DeleteDC(hdcMem);        return S_OK;    }    OLE_COLOR m_clrFillColor;    HBITMAP        m_hBitmap;};

 

参考:

1,ATL窗口添加背景图片 

http://blog.163.com/l1_jun/blog/static/14386388201092521520392/