Processing Trackbar Notification Messages

The following example is a function that is called whenever a WM_HSCROLL message is received by the dialog box containing the trackbar. The trackbar has the TBS_ENABLESELRANGE style. The position of the slider is compared against the selection range, and the slider is moved to the starting or ending position of the selection range, when necessary.

A dialog containing a trackbar with the TBS_VERT style could use this function when it receives a WM_VSCROLL message.

// 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)) {


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);






Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database