-
OK, I'm only posting this because you have to finish by tomorrow and I'm going. I suggest you think about it a bit more before reading on. MoveWindow is irrelevant. The important fact is that GetDlgItem(hwnd, ID_PROGRESS) is failing after the call to SetParent(). Why?
After you call SetParent(), hwnd is no longer the parent of ID_PROGRESS. Therefore:
Code:
GetDlgItem(hwnd,ID_PROGRESS)
will fail. The new parent is the status bar so we have to use that in the call to GetDlgItem with the equivalent of:
Code:
GetDlgItem(GetDlgItem(hwnd, ID_STATUS), ID_PROGRESS)
Here is the code that I used:
Code:
case WM_INITDIALOG:
{
RECT rc;
HWND hwndStatus = GetDlgItem(hwndDlg, ID_STATUS);
HWND hwndProgress = GetDlgItem(hwndDlg, ID_PROGRESS);
SetParent(hwndProgress, hwndStatus);
SendMessage(hwndProgress, PBM_SETPOS, 50, 0);
GetClientRect(hwndStatus, &rc);
MoveWindow(hwndProgress, rc.left + 1, rc.top + 1, rc.right - 2, rc.bottom - 2, TRUE);
return TRUE;
}
case WM_SIZE:
{
RECT rc;
HWND hwndStatus = GetDlgItem(hwndDlg, ID_STATUS);
HWND hwndProgress = GetDlgItem(hwndStatus, ID_PROGRESS);
SendMessage(hwndStatus, WM_SIZE, wParam, lParam);
GetClientRect(hwndStatus, &rc);
MoveWindow(hwndProgress, rc.left + 1, rc.top + 1, rc.right - 2, rc.bottom - 2, TRUE);
break;
}
and the RC contents:
Code:
CONTROL "", ID_STATUS, STATUSCLASSNAME, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0
CONTROL "", ID_PROGRESS, PROGRESS_CLASS, WS_CHILD | WS_VISIBLE, 0, 0, 100, 10
-
Code:
MoveWindow(GetDlgItem((GetDlgItem(hwnd,ID_STATUS_SEARCH)),ID_PROGRESS), rect.left, rect.top, rect.right, rect.bottom, TRUE);
is that it?
-
yep thanks, that looks like thats it!, ive got a question, i just want the progress bar in one part of the status bar, i mean i have it in all of it, but i want to keep my status bar in three pieces and in one piece will be some text, the next the progress bar, and the other more text, is there a function like SB_SET or something to put it in the second part?
-
nevermind i think i might have gotten it, sorry! and thanks!
-
im trying to get the progress bar to move, but it wont, heres what i got
Code:
SendMessage(GetDlgItem((GetDlgItem(hwnd,ID_STATUS_SEARCH)),ID_PROGRESS),PBM_SETSTEP,(WPARAM)10,0);
SendMessage(GetDlgItem((GetDlgItem(hwnd,ID_STATUS_SEARCH)),ID_PROGRESS),PBM_STEPIT,0,0);
-
Ok, im working with the progress bar, is there a way to make the timer start a specific time, lets say when the user clicks a button, and then make it stop when when the function is done instead of making it work for a certain amount of time? like instead of putting a 5 second lapse at 5000 make it go until a function is done?