Original Post
Hello,
I''m trying to load a CBitmap from a file using a HBitmap and attach() , but my program keeps on crashing whenever I delete the pointer to the dialog box to close it(doing a modless dialog box toolbar thingy). I''m guessing I have a memory leak somewhere but it''s getting very frustrating. The only time it seems to not crash on exit is when the attach() method is not called (of course then I can''t see my bitmap).any comments would be greatly appreciated. thanks.
void CTileSelector::OnPaint()
{
CPaintDC dc(this); // device context for painting
CBitmap ImageList;
/*hImage is a global HBITMAP which has been previously loaded with a bitmap file.*/
ImageList.Attach(hImage)
SIZE ImageSize;
BITMAP bmp;
ImageList.GetObject(sizeof(BITMAP),&bmp)
CDC dcMem;
dcMem.CreateCompatibleDC(NULL);
dcMem.SelectObject(&ImageList);
ImageSize.cx=bmp.bmWidth;
ImageSize.cy=bmp.bmHeight;
dc.BitBlt(xc,10,32,32,&dcMem,ix,iy,SRCCOPY);
dcMem.DeleteDC();
ImageList.Detach();
ImageList.DeleteObject();
}