Advertisement Jump to content


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


Correct Processing of WM_PAINT

This topic is 6779 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''m currently coding my editor, so this is a win32 api question.. When my app redraws itself after a resize, i get a flicker. Whats happening is the main window is redrawing it''s client area with solid grey, then all my controls on it are redrawing themselves.. However, sometimes the controls themselves leave traces when they redraw. Can anyone enlighten me on the proper method for redrawing a window? Or atleast how to aviod the flicker.. (I''ve tried a few ws_ styles, but they seem to cause more wierd stuff to happen..) -Zims

Share this post

Link to post
Share on other sites
ok, i honestly have to say i have absolutely no reason for suggesting that you try these, except that they might work, and for this reason it is not the *right* way to solve your problem, cuz you should know *why* you have the problem you have, not just guessing and checking, cuz it could cause bugs later, but here are some suggestions:

1: when you fill in your wndclass(ex).style, try CS_OWNDC, CS_HREDRAW, and CS_VREDRAW (you''ve probably already done this...)

2: when you repaint your window in response to WM_PAINT, use BeginPaint and EndPaint, and i think there is a function call to retrieve the client area that actually needs updating, instead of updating the whole thing, so you know which region needs to be updated if the window was obscured by another window. or, you could use
InvalidateRect (hWndOfTheWindowYouWantToDraw, rectThatSpecifiesTheSizeOfYourClientArea, boolThatSaysWhetherOrNotYouWishTheBackgroundToBeErased)
so you pass that function your hWnd, a rect that has the coordinates of the client area you Want to redraw, and a true/false flag saying if you want to erase the background. btw, i havent'' used this function, but it should work, cuz thats what MSDN lib says...

3: try specifying CS_SAVEBITS in the style member of your wndclass(ex), you will not recieve any wm_paint messsages, because the system will redraw from a bitmap it saves before the window is moved. however, this will probably slow your app a bit, and it will take up a little extra memory. (easy, though).

Sometimes even chickens need to eat... Don't bang your head against a wall just to enjoy the good feeling when you stop.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!