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