Correct Processing of WM_PAINT

Started by
1 comment, last by Zimans 23 years, 9 months ago
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
Advertisement
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.
Yesterday is the past, tomorrow is the future. Today is a gift, that is why we call it the present.
Try adding these flags

WS_CLIPCHILDREN / WS_CLIPSIBLINGS

This topic is closed to new replies.

Advertisement