Click to See Complete Forum and Search --> : Status bar problem
susiriss
August 25th, 2004, 06:57 AM
Dear friends,
I have created a status bar for my main window under WM_PAINT of main window procedure using CreateWindowEx.The problem is that status bar does not resize when the window is resized although I've sent WM_SIZE for the status bar under WM_SIZE of main window procedure. This make several status bars to remain in the window.
What sort of actions can I take to avoid this. I used WS_CLIPCHILDREN for the main window and WS_CLIPSIBLINGS for the status bar.
You always helped me.
Thanks
Susiriss.
Bond
August 25th, 2004, 08:03 AM
You're creating the status bar during WM_PAINT? Do I understand you correctly?
If so, that's not good.
Bond
August 25th, 2004, 08:08 AM
Here's is a WM_SIZE handler that resizes a status bar from a program I wrote a while ago:
case WM_SIZE:
{
// Get the new width and height of the dialog...
int iWidth = LOWORD(lParam);
int iHeight = HIWORD(lParam);
SendMessage(hStatusBar, WM_SIZE, 0, 0);
// Re-establish the status bar panels (5 panels in all)...
int iArray[5];
int iPanelWidth = iWidth / 5;
for (int i = 0; i < 5; i++)
iArray[i] = (i + 1) * iPanelWidth;
// Tell the status bar to set the status bar window parts...
SendMessage(hStatusBar, SB_SETPARTS, 5, (LPARAM) iArray);
return FALSE;
}
susiriss
August 26th, 2004, 12:25 AM
Yes Bond,
I've created the status bar while WM_PAINT. The same problem arose for my owner-draw list box created in WM_PAINT. It just resolved after removing it from WM_PAINT. So, it seems like the status bar needs the same treatment, isn't it ?
Thanks for your suggestion
susiriss
Bond
August 26th, 2004, 08:13 AM
Yes Bond,
I've created the status bar while WM_PAINT. The same problem arose for my owner-draw list box created in WM_PAINT. It just resolved after removing it from WM_PAINT. So, it seems like the status bar needs the same treatment, isn't it ?
susiriss
Yes. WM_PAINT is sent to your dialog/window everytime it needs to be repainted. If you minimize/maximize, if another window covers part of yours, if any hot tracking features take place, etc, your window will need to repaint itself.
You don't want to create a status bar everytime this happens -- just once. So you would use WM_INITDIALOG or some other event that happens only once.
You should only use WM_PAINT for painting -- not creating new windows. And if you do need to use WM_PAINT, you should do whatever you need to do as quickly as possible.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.