I have an C++ MFC program and I'm trying to use a couple of horizontal sliders.
I already added ON_WM_HSCROLL()
to my Message Map and I have this function to deal with changes in any slider:
void CAppDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
switch (pScrollBar->GetDlgCtrlID()) {
case IDCAM1_ZOOMSLIDE:
// do stuff
return;
case IDCAM2_ZOOMSLIDE:
// do stuff
return;
default:
return;
}
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
I tried to put a breakpoint on the switch line and realized that every time I change the slider, OnHScroll() is executed 2 times.
Why is that and how can I change this behavior?
Thanks
As Steve Wellens suggested,
I'm not using the nSBCode
.
OnHScroll
is being executed the first time with nSBCode=SB_PAGELEFT
and a second time with nSBCode=SB_ENDSCROLL
.
A simple switch
or if
is enough to deal with this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With