本文共 917 字,大约阅读时间需要 3 分钟。
显示ICON图标,如下:
1 2 3 4 5 6 7 8 9 | static HICON hIcon = ( HICON )::LoadImage( AfxGetInstanceHandle(), TEXT( "1.ico" ), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_LOADFROMFILE); CClientDC dc( this ); dc.DrawIcon( 350,150,hIcon); |
显示bmp位图,如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | static HBITMAP hBitmap = ( HBITMAP )::LoadImage( NULL, TEXT( "1.bmp" ), IMAGE_BITMAP, 50, 50, LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_LOADFROMFILE); CBitmap bmp; bmp.m_hObject = hBitmap; CDC memDC; //使用兼容位图DC memDC.CreateCompatibleDC(GetDC()); memDC.SelectObject(bmp); BITMAP bmpInfo; bmp.GetBitmap(&bmpInfo); bool ret = dc.BitBlt(350,200,bmpInfo.bmWidth,bmpInfo.bmHeight,&memDC,0,0,SRCCOPY); //透明位图 //dc.TransparentBlt(350,200,bmpInfo.bmWidth,bmpInfo.bmHeight,&memDC, //0,0,bmpInfo.bmWidth,bmpInfo.bmHeight,RGB(255,255,255)); |