Advertisement

Drawing bitmaps without MFC

Started by January 08, 2003 09:43 AM
2 comments, last by SinnDarin 21 years, 10 months ago
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
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):

  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.
Advertisement
[EDIT] (better answer already posted b4 me)

[edited by - DerekSaw on January 8, 2003 11:15:00 AM]
"after many years of singularity, i'm still searching on the event horizon"
thks a lot

This topic is closed to new replies.

Advertisement