#include #include #include "winlib.h" 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(); // Create the status window. hwnd = CreateWindowEx( 0, STATUSCLASSNAME, (LPCTSTR) NULL, SBARS_SIZEGRIP | WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hwndParent, NULL, hInst, NULL); SetStatusParts(hwndParent, nParts); return hwnd; } void ShowStatus(HWND hwnd, int n, char *s) { SendMessage(hwnd, SB_SETTEXT, (WPARAM)n, (LPARAM)(LPSTR)s); } .