Skip to main content
GameDev.net gamedev.net
🔒 Locked

MFC GDI CreateBitmap Question

Started by jho Sep 6, 2000 at 5:29 PM 0 replies 1k views
Original Post
jho
jho
I'm no GDI / MFC expert but I want to make sure my program de-allocate things correctly. Here's some of my code for a Rendering window: (CWnd) ==================== member variables: CDC m_memDC; //memory device context CDC * m_screenDC; //screen device context CBitmap m_memBM; //memory bitmap OnCreate(): m_screenDC = GetDC(); m_memBM.CreateCompatibleBitmap(m_screenDC, rect.Width(), rect.Height()); m_memDC.CreateCompatibleDC(m_screenDC); m_memDC.SelectObject(&m_memBM); OnDestroy(): ReleaseDC(m_screenDC); OnPaint() m_screenDC->BitBlt(0,0,m_screenWidth, m_screenHeight, &m_memDC, 0, 0, SRCCOPY); //bitblt to screen ============================== Did I forget to free up something? What about my Bitmap, m_memBM? I'm doing this to do flicker free rendering. I have also one question, right now I setup my bitmaps in OnCreate because my app isn't resizable, what if I wanted my app to be resizable, do I move the setup code from OnCreate to OnSize? it SEEMS wrong to call CreateBitMap() over and over whenever I resize my window? Edited by - jho on 9/6/00 5:42:09 PM
baskuenen
baskuenen
I never saw anything like this in any examples, but I''m using it myself, and it seems to work perfect

    
HBRUSH hBrush = CreateBrush(...);
HBRUSH hBrushPrev = SelectObject(hBrush); // returns previous brush

...
DeleteObject(SelectObject(hBrushPrev)); // SelectObject returns previous brush (our brush)


Sorry - only know Win32 -

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.