I have a progress bar that just fits nicely in my status bar. I placed the progress bar by trial and error cuz I don't know the exact size/location of the status bar. Is there any way to find the size/location? My method seems very unscientific and it doesn't work is a user changes the window settings, e.g 'Caption Buttons' size or 'Title Bar' size.


The Win API says in part:

"The CreateStatusWindow function calls the CreateWindow function to create the window. It passes the parameters to CreateWindow without modification and sets the position, width, and height parameters to default values."




any help appreciated,

best regards,

czDrillard
Posted on 2002-04-11 10:24:24 by czDrillard
Get the sizes you need with GetWindowRect/GetClientRect (depending on the area you need), and do some calculations..
Here's an example from one of my programs that resizes the MDI client window to make the toolbar and statusbar fit:



...on WM_SIZE....
SendMessage(hStatusWin,WM_SIZE,wParam,lParam);
SendMessage(hToolbar,WM_SIZE,wParam,lParam);
GetWindowRect(hStatusWin, &tmpRect);
GetWindowRect(hToolbar, &tmpRect2);
tmp = tmpRect2.bottom - tmpRect2.top;
MoveWindow(hwndMDIClient,0,tmp,
LOWORD(lParam),
HIWORD(lParam) - (tmpRect.bottom-tmpRect.top) - tmp,
true);


Thomas
Posted on 2002-04-11 10:40:21 by Thomas
Thanks Thomas,

That will take the guess work out of it :)

Btw, do you know of any method for setting the statusbar size to anything other than the default values? (Determined by font sizes etc)

best regards,

czDrillard
Posted on 2002-04-12 09:48:31 by czDrillard
I think a status bar will size (and move) itself automatically. Just send a WM_SIZE message to it when it has to resize itself again..

Thomas
Posted on 2002-04-12 11:01:08 by Thomas