트랙바 알림 메시지를 처리하는 방법
트랙바는 부모 창에 WM_HSCROLL 또는 WM_VSCROLL 메시지를 전송하여 사용자 작업의 부모 창을 알립니다.
알아야 하는 작업
기술
필수 구성 요소
- C/C++
- Windows 사용자 인터페이스 프로그래밍
지침
트랙바 알림 메시지 처리
다음 코드 예는 트랙바의 부모 창이 WM_HSCROLL 메시지를 수신할 때 호출되는 함수입니다. 이 예의 트랙바에는 TBS_ENABLESELRANGE 스타일이 있습니다. 슬라이더의 위치를 선택 범위와 비교하여 필요한 경우 슬라이더를 선택 범위의 시작 위치 또는 끝 위치로 이동합니다.
// TBNotifications - handles trackbar notifications received
// in the wParam parameter of WM_HSCROLL. This function simply
// ensures that the slider remains within the selection range.
VOID WINAPI TBNotifications(
WPARAM wParam, // wParam of WM_HSCROLL message
HWND hwndTrack, // handle of trackbar window
UINT iSelMin, // minimum value of trackbar selection
UINT iSelMax) // maximum value of trackbar selection
{
DWORD dwPos; // current position of slider
switch (LOWORD(wParam)) {
case TB_ENDTRACK:
dwPos = SendMessage(hwndTrack, TBM_GETPOS, 0, 0);
if (dwPos > iSelMax)
SendMessage(hwndTrack, TBM_SETPOS,
(WPARAM) TRUE, // redraw flag
(LPARAM) iSelMax);
else if (dwPos < iSelMin)
SendMessage(hwndTrack, TBM_SETPOS,
(WPARAM) TRUE, // redraw flag
(LPARAM) iSelMin);
break;
default:
break;
}
}
설명
TBS_VERT 스타일 트랙바가 포함된 대화 상자는 WM_VSCROLL 메시지를 수신할 때 이 함수를 사용할 수 있습니다.
관련 항목