Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bitmap drawing...

Status
Not open for further replies.

tchouch

Programmer
Apr 18, 2001
300
DE
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top