The easiest way - write in OnDraw() - Function Yours CView - derived class (MFC):
HDC hdcMem = CreateCompatibleDC(pDC->m_hDC);
if(hdcMem) {
HGDIOBJ hobj = SelectObject(hdcMem, hBitmap);
if(hobj) {
RECT rct;
GetClientRect(&rct);
BitBlt(pDC->m_hDC, 0,0, rct.right, rct.bottom,
hdcMem,0, 0, SRCCOPY);
}
DeleteDC(hdcMem);
}
Here: hBitmap - handle of Your Bitmap (You should return from Your class this handle too, if You wish easy draw bitmaps).
pDC - argument of OnDraw().
In Non - MFC applications, You must play with clipping regions and messages(WM_SHOWWINDOW, WM_MOVING, WM_SIZING, WM_WINDOWPOSCHANGING ) to right redraw the bitmap.
HDC hdcMem = CreateCompatibleDC(pDC->m_hDC);
if(hdcMem) {
HGDIOBJ hobj = SelectObject(hdcMem, hBitmap);
if(hobj) {
RECT rct;
GetClientRect(&rct);
BitBlt(pDC->m_hDC, 0,0, rct.right, rct.bottom,
hdcMem,0, 0, SRCCOPY);
}
DeleteDC(hdcMem);
}
Here: hBitmap - handle of Your Bitmap (You should return from Your class this handle too, if You wish easy draw bitmaps).
pDC - argument of OnDraw().
In Non - MFC applications, You must play with clipping regions and messages(WM_SHOWWINDOW, WM_MOVING, WM_SIZING, WM_WINDOWPOSCHANGING ) to right redraw the bitmap.