Jump to content
  • Advertisement
Sign in to follow this  
enigmatix

[Win32] GetDC and ValidateRect in WM_PAINT

This topic is 2904 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

Hey Guys,

I'm writing paint handler that handles painting the BG and foreground of a control. I'm using GetDCEx() to paint to the control and ValidateRect() afterward to make sure the WM_PAINT message isn't sent all the time. I also use GetUpdateRgn() to set up the clipping region so that it only paints where it needs to.

This all works fine and dandy up until the point I start moving a window above mine. At first it seems fine, but every so often it will leave bits from the window above.

I can't seem to nail down why this is happening.

Any ideas/thoughts?

...and using BeginPaint/EndPaint is not the solution I am looking for.

Share this post


Link to post
Share on other sites
Advertisement
Well, what's happening is your WM_PAINT handler isn't painting some region that it needs to paint. This probably has to do with your calls to ValidateRect. If you take out all calls to ValidateRect does the painting bug still occur?

EDIT: Just read your post more closely ... so are you painting outside of BeginPaint()/EndPaint() when handling WM_PAINT? Why?

Share this post


Link to post
Share on other sites
Yes, actually. I was thinking it might be the validation, but when I validate the only the update region as opposed to the entire client area, it still does the same. So I'm confused, if the update region is what needs to be updated, and I validate it, that should do it...

Share this post


Link to post
Share on other sites
Post some code...

But basically your WM_PAINT handler should be painting to the HDC returned from BeginPaint(), period. Are you not doing this?

Share this post


Link to post
Share on other sites
Ah, I seem to have located the problem and you were right initially. It was not drawing over the area where the window above had been. I was using FillRgn or FillRect passing in the Update region/rect to erase the area. Using FillRect with the client rect seems to do the trick...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!