To reduce flickering I create my parent windows using the WS_CLIPCHILDREN flag and I call InvalidateRect during the WM_SIZE event. This approach has worked well in Windows XP. However, I recently started programming on Windows 7 and I'm now experiencing rendering issues when resizing windows. When resizing a window its contents is not refreshed until I do something that forces a redraw, like minimizing and restoring the window.
I've tried following up the InvalidateRect with a UpdateWindow call but with no effect.
Does anyone know how to do it correctly?
Edit
I found a workaround: calling
InvalidateRect(childHWND, NULL, FALSE)
on all child windows followed by a InvalidateRect(parentHWND, NULL, TRUE)
on the parent window fixes the rendering problem without introducing noticable flickering.
Other suggestions are still welcome!
Edit2
@interjay: I tried the ::RedrawWindow(handle(), 0, 0, RDW_INVALIDATE | RDW_ALLCHILDREN);
but that resulted in some rendering issues (left-over pixels):
Edit3
The RedrawWindow works when followed by a ::InvalidateRect(handle(), NULL, TRUE)
. Thanks @interjay!