-
status bar flickering
Hi there,
I noticed that when I add a status bar to my applications that they flicker excessivily when I resize them. Has anyone else noticed this? I have made a rich edit control window using Windows API which did not flicker when it was resized until I added a status bar. When I add the status bar I don't get flickering until I add this line of code under the WM_SIZE switch case...
Code:
MoveWindow( hStatusBar, 0, 0, LOWORD(lParam), HIWORD(lParam), false );
Is there anyway to get rid of this behavior?
-
Handle the WM_ERASEBKGN msgs (return non zero)?
-
That seems to work but it causes a few other issues with my window, I think I can find a work around though. I found some other materials related to this, they seem to blame common controls a lot. Here are some links in case anyone else with the same problem finds this thread...
http://msdn2.microsoft.com/en-us/library/ms969905.aspx
http://www.catch22.net/tuts/flicker.asp
-
I think you're probably over complicating things - just make sure your richedit control's bottom edge takes account of the status bar's position so both controls are not trying to draw over each other. In other words, use MoveWindow on the richedit control, too, in the parent's WM_SIZE handler to ensure its base is flush with the top edge of the status bar.
If your controls cover the entire client area then it's probably a good idea to handle the parent's WM_ERASEBKGND message as described by Novacain or create the parent with a NULL brush since there's no point in drawing it. The WS_CLIPSIBLINGS window style may prove useful if used with overlapping child controls where you can't simply arrange them so they don't overlap.
-
MoveWindow? Here is what I used for my status bar:
Code:
GetClientRect(hwnd, &rcClient);
SetWindowPos(hStatusBar, NULL, 0, rcClient.bottom-10, rcClient.right, 10, SWP_NOZORDER);
Use this if you want the status bar to dock on to the bottom of the window. The 10 is the height of the status bar. If you are actually trying to resize the status bar itself (I haven't yet seen an approach where this might be a good solution, SetWindowPos might not be the best way. The parameters for SetWindowPos() are as follows: hwnd, hwnd, x, y, width, height, flags. Hope this helps.
-
Actually, the statusbar pretty much knows how to size itself when sent a WM_SIZE message with out need for dimensions. The richedit control needs to be sized/positioned to account for the statusbar's dimensions, specifically its height, and, while SetWindowPos is certainly a good option, MoveWindow is simpler to use. Something like:
Code:
case WM_SIZE:
{
SendMessage(hStatusbar,WM_SIZE,0,0);
RECT rc;
GetClientRect(hStatusbar,&rc);
int statbar_height = rc.bottom - rc.top;
MoveWindow(hRichedit,0,0,LOWORD(lParam),HIWORD(lParam) - statbar_height,0);
return 0;
}