repainting a window
I'm confused a little about system of repainting in Windows. If I send window a WM_PAINT message, it usally does nothing, because the update rectangle is empty. So I use InvalidateRect function to set the update rectangle. But my program also draws in the client area some graphics and on slow computers I could experience "flickering" effect on the toolbar. I found out that this is because the update rectangle is in such cases set to whole window. I found in help that you can use CS_CLIPSIBLINGS (or something like this) class style to let Windows remove all child windows from the update rectangle. But when I use it, buttons on toolbar stay pressed when I click them.
All I need to do is a program that redraws everything except child windows (I have a toolbar and a statusbar) everytime I send a WM_PAINT message to the main window and that redraws toolbar or statusbar whenever it's needed (user clicks a button on the toolbar or statusbar text changed).
use the ws_clipchildren style for the parent of the toolbar.
When you use InvalidateRect(hwnd,&rc,0 or 1) make sure that the update rect does NOT include the toolbar ( you can always invalidate that separately, if required).
Apparently flicker isn't a problem with winxp due to the doubl-buffering introduced with gdi+.
you shouldn't really send the WM_PAINT message explicitly.. use UpdateWindow() instead. :)
return TRUE for WM_ERASEBKGND msg to stop flicker.
use GetUpdateRect() in the paint function before calling BeginPaint()
GetUpdateRect(hWnd, &theRect, 0);
//set the area here to repaint if not what you want or