Skip to main content
gamedev.net
🔒 Locked

quick MFC cleanup question

Started by Askadar Dec 31, 2001 at 6:58 AM 1 replies 1.1k views
Original Post
Askadar
Askadar
Hi everybody, I''m using LoadImage to load an image and then attach to a CBitmap. So far no problem. But who''s now responsible for cleaning up the HBITMAP? Will the MFC framework do it, or is it still my job?
Kill mages first!
kvh
kvh
As soon as you Attach() the handle to the CBitmap, the CBitmap becomes responsable, the handle will be released in it''s destructor.

If you want to prevent the handle from being released when the CBitmap goes of scope, you have to Detach() it again. Then you''re responsable again.


btw: The entire MFC source comes with Visual Studio, you can do ''Edit/Find in files'', set the ''in folder'' box to something like ''c:\Program Files\MICROSOFT VISUAL STUDIO\VC98\MFC\SRC'' and enter a search term, for example ''~CBitmap'' and ''CGdiObject::DeleteObject''
Askadar
Askadar
Thank you.
Kill mages first!

Topic Locked

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

Sign in to reply to this topic.