Inside the handler check the lower word of the
WPARAM
. It contains the notification code (e.g.
TB_LINEDOWN
for a step to the right and
TB_LINEUP
for a step to the left with horizontal bars when using the keyboard). When using the mouse,
TB_THUMBTRACK
is send while moving with left mouse button down and
TB_THUMBPOSITION
is send when the mouse button is released. See
About Trackbar Controls (Windows)[
^].
You already know how to get the current position: By sending the
TBM_GETPOS
message.
However, with the
TB_THUMBTRACK
and
TB_THUMBPOSITION
notifications the position is send in the high word of the
WPARAM
. See
WM_HSCROLL (Trackbar) notification code (Windows)[
^].
This will not work as expected:
switch (HIWORD(wParam))
{
case WM_HSCROLL:
As explained the above, the high word is the position with the track and position events (and zero with all other track bar scroll events). The switch statement must use the message code instead.