// Do not call CFrameWnd::OnPaint() for painting messages }
CButton::SetBitmap HBITMAP SetBitmap( HBITMAP hBitmap );Return ValueThe handle of a bitmap previously associated with the button. CStatic::SetBitmap HBITMAP SetBitmap( HBITMAP hBitmap );Return ValueThe handle of the bitmap previously associated with the static control, or NULL if no bitmap was associated with the static control.
如何动态加载位图资源?LoadImage Function
The LoadImage function loads an icon, cursor, animated cursor, or bitmap.
HBITMAP hBmp = (HBITMAP)::LoadAnImage(NULL, "mybmp.bmp",IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
dc.DrawState(pt, size, hBmp, DST_BITMAP | DSS_NORMAL);
CBitmap bitmap;
Bitmap bmp;
bitmap.LoadBitmap(IDB_BITMAP);
bmp.GetBitmap(&bitmap);
2.创建兼容DC:
CDC dcCompatible;
dcCompatible.CreateCompatible(pDC);
3.将位图选到兼容DC 中去:
dcCompatible.SelectObject(&bmp);
4.将兼容DC中的位图贴到当前DC中:
pDC->BitBlt(...);
bg->m_hObject=(HBITMAP)::LoadImage(NULL,
"bground.bmp",IMAGE_BITMAP,720,540,LR_LOADFROMFILE);
void XXXX::OnPaint()
{
CPaintDC dc(this); // device context for painting
pdc->SelectObject(bg);
mdc->BitBlt(0,0,bwidth,bheight,pdc,0,0,SRCCOPY);
dc.BitBlt(0,0,bwidth,bheight,mdc,0,0,SRCCOPY);
// TODO: Add your message handler code here
// Do not call CFrameWnd::OnPaint() for painting messages
}
HBITMAP SetBitmap( HBITMAP hBitmap );Return ValueThe handle of a bitmap previously associated with the button.
CStatic::SetBitmap
HBITMAP SetBitmap( HBITMAP hBitmap );Return ValueThe handle of the bitmap previously associated with the static control, or NULL if no bitmap was associated with the static control.