张晓华的博客

        2005年,最后一场雪,还是下了,虽然凄凉了一些!
posts - 185, comments - 100, trackbacks - 8, articles - 1

在ActiveX中显示图片(其他程序中通用)

Posted on Saturday, June 21, 2008 1:06 PM
CString szFilename ("c:\\temp\\1678391_6878.bmp");
 
CDC   *dc   =   GetDC();  
CDC bmDC;
 HBITMAP hBmp = (HBITMAP)::LoadImage(NULL,szFilename,IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
 CBitmap bmp;
 bmp.Attach(hBmp);
bmDC.CreateCompatibleDC(dc);
CBitmap *pOldbmp=bmDC.SelectObject(&bmp);
BITMAP bi;
bmp.GetBitmap(&bi);
dc->BitBlt(0,0,bi.bmWidth,bi.bmHeight,&bmDC,0,0,SRCCOPY);
bmDC.SelectObject(pOldbmp);

Post Comment

Title  
Name  
Url
Comment   
Protected by Clearscreen.SharpHIPEnter the code you see: