|
-
March 29th, 1999, 02:58 AM
#1
Re: How do I use IPictureDisp in ATL?
Try sticking the following code in the OnDraw handler:
// Draw the background image
IPicture *pPic;
HBRUSH hBrush;
HPEN hPen, hPenOld;
HBITMAP hBmp, hBmpOld;
HDC hDC;
BOOL bBitBlt;
m_pPicture->QueryInterface(IID_IPicture, (void**)&pPic);
// Get the OLE picture object's handle
if(pPic){
pPic->get_Handle((OLE_HANDLE*)&hBmp);
pPic->Release();
pPic = NULL;
}
// Create a memory DC
hDC = CreateCompatibleDC(di.hdcDraw);
// Select the bitmap into the memory DC
hBmpOld = (HBITMAP)SelectObject(hDC, hBmp);
// Blt the bitmap from the memory dc to the screen
bBitBlt = BitBlt(di.hdcDraw,
di.prcBounds->left,
di.prcBounds->top,
di.prcBounds->right - di.prcBounds->left,
di.prcBounds->bottom - di.prcBounds->top,
hDC,
0,
0,
SRCCOPY);
// Select the old bitmap back into the memory DC
hBmp = (HBITMAP)SelectObject(hDC, hBmpOld);
// Delete the memory DC
DeleteDC(hDC);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|