Archived

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

out of DC's but WHY?!!!!!!!? GDI

This topic is 5505 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have been working on this for 2 weeks now. I just can''t figue out why my computeer crashes with this code. //some notes //CBlock[x][y] is color postion and a bool for paint or no paint. //hrgnCell[x][y] is the postion and size. // I took the error cheaking out for simpicity. // this crashes becuase I ran out of DC but Why? case WM_PAINT: hdc = BeginPaint(hdlg, &ps); for(x=0; x

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
don''t see why off hand. maybe it''s in another part of your code?

btw, if you''re always just going to be filling rects, try FillRect instead of FillRgn. you can use your rect w/o having to create/delete a rgn.

also, you don''t need to select/de-select your brush into the DC, either with FillRgn or FillRect. just create it, use it, delete it.

one final thought: move this code to a function that only gets called when the image your building up needs to be updated. and have that function build up a bitmap to represent the final image. then for WM_PAINT, just select the bitmap into the DC, blit it, and de-select it. much, much faster and less prone to resource leakage.

Share this post


Link to post
Share on other sites
I had a problem in Win95 (fixed in 98/NT+) that if you deleted a DC without selecting-out its bitmap first, that DC would leak (I believe--it was a weird bug that only appeared on one platform). Anyway, odds are the bug's somewhere else. Things look fine here.

Question: why aren't you using FillRect instead of FillRgn? You'd be able to get away with not creating/destroying a region for every object.

Edit: heh, just noticed the AP said the same thing. Sorry.

[edited by - Stoffel on November 19, 2002 12:41:13 PM]

Share this post


Link to post
Share on other sites