July 17th, 2009, 06:37 AM
hi, when i Attach() a bitmap from file to a CBitmap like this:
will bmp.Detach() free the memory correctly? or do i need to just use bmp.DeleteObject()? or both?
bmp.Attach((HBITMAP)LoadImage(NULL, GetAppPath() + "\\Images\\background.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION));
i tried searching for the Detach() function but i couldn't find anything..
Last edited by eXistenZ; July 17th, 2009 at 06:45 AM.
July 17th, 2009, 06:49 AM
CGdiObject:etach method, derived by CBitmap from CGdiObject, detaches GDI object handle from class instance, but doesn't release the haNDLE. So, iF you want to continue working with HBITMAP directly, without bmp object, use Detach:
HBITMAP hBmp = (HBITMAP)bmp.Detach();
If you want to release bitmap, use DeleteObject. In any case, wheN CBitmap instance is destroyed, it released HBITMAP, if one is attached.
July 17th, 2009, 06:52 AM
ah, i see, thank you!
Originally Posted by Alex F
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.