david3de
david3de

Reputation: 41

Using ON_WM_HSCROLL() while still having a functional default scrollbar?

I am writing an MFC application which uses the CSliderCtrl class to control a slider. I have the ON_WM_HSCROLL() message in my message map, but this arises with the problem that this disables the default window scrollbar that appears at the bottom of the view when the windows is too small. Manipulating it does nothing to the window. What do I have to do in order to preserve functionality in that scrollbar?

Currently, my OnHScroll() function simply looks like:

void myClass::OnHScroll(UINT nSHCode, UINT nPos, CScrollBar* pScrollBar) 
{
    if (*pScrollBar == mySlider)
    {
    // do stuff
    }
}

Upvotes: 0

Views: 787

Answers (1)

Andrew Komiagin
Andrew Komiagin

Reputation: 6556

You still need to call the default handler defined in base/parent class: CDialog::OnHScroll(nSBCode, nPos, pScrollBar); in case of dialog window or CFormView::OnHScroll(nSBCode, nPos, pScrollBar); in case of SDI/MDI view.

So your handler will look like this:

void myClass::OnHScroll(UINT nSHCode, UINT nPos, CScrollBar* pScrollBar) 
{
    if (*pScrollBar == mySlider)
    {
    // do stuff
    }

    CDialog::OnHScroll(nSBCode, nPos, pScrollBar)
}

Upvotes: 1

Related Questions