-
July 17th, 2009, 06:37 AM
#1
CBitmap::Detach()
hi, when i Attach() a bitmap from file to a CBitmap like this:
Code:
CBitmap bmp;
bmp.Attach((HBITMAP)LoadImage(NULL, GetAppPath() + "\\Images\\background.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION));
will bmp.Detach() free the memory correctly? or do i need to just use bmp.DeleteObject()? or both?
i tried searching for the Detach() function but i couldn't find anything..
thanks
Last edited by eXistenZ; July 17th, 2009 at 06:45 AM.
-
July 17th, 2009, 06:49 AM
#2
Re: CBitmap::Detach
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
#3
Re: CBitmap::Detach
Originally Posted by Alex F
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.
ah, i see, thank you!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|