Just handle the
OnHScroll()
or
OnVScroll()
message as described in
Slider notification messages[
^]. When the user moves the slider and releases the mouse button, a
TB_THUMBPOSITION
notification is send (
nSBCode
parameter of the scroll handler). The position is passed in the
nPos
parameter and a pointer to the slider control in the
pScrollBar
parameter (this must be casted to
CSliderCtrl*
).
[UPDATE: Example code]
If not done so far, add the
WM_HSCROLL
handler to your dialog and optional a member variable for the slider:
void CMyDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
if (IDC_SLIDER == pScrollBar->GetDlgCtrlID())
{
switch (nSBCode)
{
case TB_LINEUP:
case TB_LINEDOWN:
case TB_PAGEUP:
case TB_PAGEDOWN:
case TB_THUMBPOSITION:
case TB_TOP:
case TB_BOTTOM:
case TB_THUMBTRACK:
case TB_ENDTRACK:
default:
break;
}
return;
}
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}