Original Post
Hello, Well, I don' know very much about HDCs and HBITMAPS. My question is, is it possible to have a memory leak using HDCs and HBITMAPs? In my program I use multiple HDCs and HBITMAPS that are used in the WM_PAINT message and I want to know if it is possible to have a memory leak from one of these if I don't properly delete them (DeleteObject(),DeleteDC()...) or forget to delete one at one point? I also wonder if it is necessary to call ReleaseDC() each time before calling DeleteDC()? If you can get a memory leak from not deleting a DC or HBITMAP (DeleteObject), is there an east way to find out if you have a leak? I tried adding a few lines of code inside my program's WM_DESTROY message that checks: Something like that so it tells me something if that one HC has not been deleted and possibly a memory leak...but I always got that message box even if I called DeleteDC and ReleaseDC before the if statement and I figure that is the way I worded the argument in the if statement so I tried if(hdcMem != NULL). So, like I said I don' know much about how all that wroks so if you could give me some information about this that would be great. I tried searching for some things online and the only thing I found was ReleaseDC so... Thanks, Progames25
if (hdcMem)
{
MessageBox(NULL,L"hdcMem not deleted?",L"hdcMem",MB_OK);
}