Getting a CBitmap from a HBITMAP, using FromHandle()
Posted on 1998-07-09
I need to get a CBitmap from a HBITMAP, and to be able to delete my CBitmap again, when I need to.
My code looks like this:
hBitmap=(HBITMAP) LoadImage(NULL, "BitmapName.Bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
My problem is that when I come to the Destructor, and want to delete the m_bmpBitmap again, my program crashes, becourse the CBitmap is attached to a HBITMAP, and I don't know how to detach it again.
How do delete my m_bmpBitmap in a proper way (So that it won't cause the program to crash) ?