1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Bitmap invalidating

Discussion in 'MFC' started by Init, May 5, 2007.

  1. Init

    Init New Member

    Joined:
    May 5, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi,
    I made a MFC app, made a bitmap import to resources (IDB_BITMAP1) and trying to display it.
    So I made " CBitmap bm " and " CDC mem " variables in CView class and the following code was paste in OnDraw function:
    Code:
            bm.LoadBitmap(IDB_BITMAP1);
    
    	mem.CreateCompatibleDC(pDC);
    	mem.SelectObject(&bm);
    
    	pDC->BitBlt(10,10, 512, 512, &mem, 0,0, SRCCOPY);
    
    Bitmap is succesfully displayed, but after minimizing-maximizing operation programm crashes.
    I guess this is "invalidating" problem... What code do I need to paste in the programm?
    Thanks!
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    Now there are some very common mistakes you have been doing and so try and rectifying that.

    1. You have the same bitmap loading in the OnView Function and try having the bitmap loaded and just Do BitBlt in the OnView Function.
    2. Try releasing the Bitmap object if its already there or don't load if once loaded. Something like checking it to the NULL

    please share the details of the crash as well so that we can also know the context better.
     
  3. Init

    Init New Member

    Joined:
    May 5, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    shabbir, thanks for answer :) This topic is no longer actual
     

Share This Page