CreateStatusWindow 함수를 사용하거나 CreateWindowEx 함수를 사용하고 STATUSCLASSNAME 창 클래스를 지정하여 상태 표시줄을 만들 수 있습니다.
상태 표시줄을 만든 후 파트로 나누고, 각 파트에 대한 텍스트를 설정하고, 상태 표시줄 메시지를 사용하여 창의 모양을 제어할 수 있습니다.
메모
공용 컨트롤 DLL이 로드되도록 하려면 먼저 InitCommonControls 함수를 사용합니다.
알아야 할 사항
기술
필수 구성 요소
- C/C++
- Windows 사용자 인터페이스 프로그래밍
지시
상태 표시줄 만들기
다음 예제에서는 크기 조정 그립이 있는 상태 표시줄을 만들고 부모 창의 클라이언트 영역 너비에 따라 창을 네 개의 동일한 부분으로 나누는 방법을 보여 줍니다.
// Description:
// Creates a status bar and divides it into the specified number of parts.
// Parameters:
// hwndParent - parent window for the status bar.
// idStatus - child window identifier of the status bar.
// hinst - handle to the application instance.
// cParts - number of parts into which to divide the status bar.
// Returns:
// The handle to the status bar.
//
HWND DoCreateStatusBar(HWND hwndParent, int idStatus, HINSTANCE
hinst, int cParts)
{
HWND hwndStatus;
RECT rcClient;
HLOCAL hloc;
PINT paParts;
int i, nWidth;
// Ensure that the common control DLL is loaded.
InitCommonControls();
// Create the status bar.
hwndStatus = CreateWindowEx(
0, // no extended styles
STATUSCLASSNAME, // name of status bar class
(PCTSTR) NULL, // no text when first created
SBARS_SIZEGRIP | // includes a sizing grip
WS_CHILD | WS_VISIBLE, // creates a visible child window
0, 0, 0, 0, // ignores size and position
hwndParent, // handle to parent window
(HMENU) idStatus, // child window identifier
hinst, // handle to application instance
NULL); // no window creation data
// 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) * cParts);
paParts = (PINT) LocalLock(hloc);
// Calculate the right edge coordinate for each part, and
// copy the coordinates to the array.
nWidth = rcClient.right / cParts;
int rightEdge = nWidth;
for (i = 0; i < cParts; i++) {
paParts[i] = rightEdge;
rightEdge += nWidth;
}
// Tell the status bar to create the window parts.
SendMessage(hwndStatus, SB_SETPARTS, (WPARAM) cParts, (LPARAM)
paParts);
// Free the array, and return.
LocalUnlock(hloc);
LocalFree(hloc);
return hwndStatus;
}
관련 항목