Drawing bitmaps without MFC
Hi,
does anybody now how to draw a simple bitmap loaded from
resource into a single win32 window ?
I ve already tried with MFC and it works well, but I really
wanted to avoid MFC.
Please help a little beginner,
Sinn
January 08, 2003 10:07 AM
the MFC classes are almost one-to-one equivalents to standard GDI "objects." ditto for the class member functions. so, you''d pretty much do the same thing for non-MFC as you did for MFC, except maybe making some additional DeleteObject, DeleteDC calls after your BitBlt call. but anyway, here''s an example (untested):
hWnd would be your window handle. hBitmap would be your bitmap handle. x, y, w, h should be self-explanatory as well.
HDC desDC = GetDC(hWnd);HDC srcDC = CreateCompatibleDC(desDC);HGDIOBJ bmPre = SelectObject(srcDC, hBitmap);BitBlt(desDC, x, y, w, h, srcDC, 0, 0, SRCCOPY);SelectObject(srcDC, bmPre);ReleaseDC(hWnd, desDC);DeleteDC(srcDC);
hWnd would be your window handle. hBitmap would be your bitmap handle. x, y, w, h should be self-explanatory as well.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement