Is there a way to place the progress bar inside the status bar without using MFC classes, just plain simple API?
thank you.
Printable View
Is there a way to place the progress bar inside the status bar without using MFC classes, just plain simple API?
thank you.
CreateStatusBar gives you a window handle, so create a progress bar child window and place it inside one of your parts. I don't know of any specialized api calls to do it.
If I'm not mistaken, CreateStatusBar is a part of some sort of class...
oops, meant CreateStatusWindow
What I use is the next:Quote:
MSDN: This function is obsolete. Use CreateWindow instead.
But is there a simple way to do this, like getting the sub handle of the StatusBar's second part and then create it directly inside there. Or is this the only way.Code:int iBarWidths[] = {120, 285, -1};
static HWND StatusBar, hProgressBar;
/* Creating a Status Bar */
hStatusBar = CreateWindowEx(NULL, STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
hwnd, (HMENU)IDD_STATUSBAR, hInst, NULL);
SendMessage(hStatusBar, SB_SETPARTS, 3, (LPARAM) iBarWidths);
SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM) "some text 1");
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) "some text 2");
/* Creating and place the Progress Bar inside the StatusBar */
hProgressBar = CreateWindowEx(NULL, "msctls_progress32", NULL, WS_CHILD | WS_VISIBLE, 122,2,163,18,
hStatusBar, (HMENU)IDD_PROGRESS, hInst, NULL);
SendMessage(hProgressBar, PBM_SETSTEP, (WPARAM)5, 0);
I assume the parts are windows, though I'm not positive, you will always know where your second part is, so you could try WindowFromPoint to get a handle to it
Though I'm not sure this would make it easier than just making it a child window and positioning it in your parts
But that's exactly what it is right now... a child window of the statusbar control
yup I believe your stuck with that, if you're not already, SB_GETRECT might make it easier
What can I do with it, does it return a handle or something like that?Quote:
SB_GETRECT
wParam = (WPARAM) iPart;
lParam = (LPARAM) (LPRECT) lprc;
Retrieves the bounding rectangle of a part in a status window.
Returns TRUE if successful, or FALSE otherwise.
iPart
Zero-based index of the part whose bounding rectangle is to be retrieved.
lprc
Address of a RECT structure that receives the bounding rectangle.