0

If I create a memory device context CreateCompatibleDC() and then SelectObject() a bitmap I created to it. Can I just DeleteObject() the old bitmap returned by SelectObject() and let the device context delete the bitmap I created? Or do I have to keep the old bitmap around and then when no longer needed (destructor) select the old bitmap and delete the one I created? Just seems like a waste of memory to keep a bitmap around that is never going to be used.

TIA!!

df234987
  • 513
  • 2
  • 13

1 Answers1

1

No, you cannot just delete the old bitmap, because you don't own it (ie, you did not create it), and you don't know who does own it (ie, the system). So yes, you must restore the old bitmap into the HDC when you are done using the new bitmap in the HDC.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770