Archived

This topic is now archived and is closed to further replies.

saisoft

Device Contexts

Recommended Posts

I know you should release a device context when you are done with it, but do you also have to release compatible DC''s. I am loading a bitmap using GDI and I have a call: HDC hDc = CreateCompatibleDC(NULL); Do I have to release hDc along with my Display DC. Also I put all my code into one function to Display a bitmap on a WM_PAINT message. Everything works fine, but after minimizing and maximizing the window a few times, the image does not show up anymore, the background color(white) is just there. Maybe this has something to do with not releasing the compatible DC, but if I do I have to release that, I am not sure how to? Would it be like this, ReleaseDC(NULL,hDc2); I just tried the line ReleaseDC(NULL, hDc2) and I kept minimizing and mazimizing the application and a message popped up saying 90 percent of your resources are in use, I also used SelectObject and GetObject, do I have to Do something with those also? thanks alot, SaiSoft

Share this post


Link to post
Share on other sites
Update - Instead of using GetDC and ReleaseDC, I used BeginPaint and EndPaint, now my resources did not continuosly go down. It worked fine, but can someone explain why using GetDC with ReleaseDC sucked up all the resources.

thanks, Saisoft

Share this post


Link to post
Share on other sites