void SetStatusParts(HWND hwnd, int nParts)
{
RECT rcClient;
HLOCAL hloc;
LPINT lpParts;
int i, nWidth, rEdge;
HWND hwndParent;
hwndParent = GetParent(hwnd);
// Get the coordinates of the parent window's client area.
GetClientRect(hwndParent, &rcClient);
// Allocate an array for holding the right edge coordinates.
hloc = LocalAlloc(LHND, sizeof(int) * nParts);
lpParts = LocalLock(hloc);
// Calculate the right edge coordinate for each part, and
// copy the coordinates to the array.
nWidth = rEdge = rcClient.right / nParts;
for (i = 0; i < nParts; i++) {
lpParts[i] = rEdge;
rEdge += nWidth;
}
// Tell the status window to create the window parts.
SendMessage(hwnd, SB_SETPARTS, (WPARAM) nParts,
(LPARAM) lpParts);
// Free the array, and return.
LocalUnlock(hloc);
LocalFree(hloc);
}
HWND CreateStatusWnd(HINSTANCE hInst, HWND hwndParent, int nParts)
{
HWND hwnd;
// Ensure that the common control DLL is loaded.
InitCommonControls();