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.
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.
Bookmarks