OnHScroll Problem 
Author Message
 OnHScroll Problem

I have an SDI program with a CFormView. In the view, I have a horizontal
scroll bar. To process the scrollbar messages, I have overridden the
OnHScroll function.

The trouble is that the program is ignoring my calls to SetScrollPos().
It's the darndest thing, and I don't have as to what's going on.

Um, there's not really much code to show. I reduced things to their
barest essentials:

void CPDSynthView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar*
pScrollBar)
{
    if(pScrollBar != NULL)
    {
        pScrollBar->SetScrollPos(50);
    }

 CFormView::OnHScroll(nSBCode, nPos, pScrollBar);

Quote:
}

I'm ignoring the messages and telling the scrollbar to position itself
halfway in its range regardless of what message is received. This was
just to zero in on a problem for debugging purposes. The scrollbar
doesn't respond at all.

Thanks for any help.



Tue, 13 Sep 2005 05:38:35 GMT  
 OnHScroll Problem

Quote:

> I have an SDI program with a CFormView. In the view, I have a horizontal
> scroll bar. To process the scrollbar messages, I have overridden the
> OnHScroll function.

> The trouble is that the program is ignoring my calls to SetScrollPos().
> It's the darndest thing, and I don't have as to what's going on.

> Um, there's not really much code to show. I reduced things to their
> barest essentials:

> void CPDSynthView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar*
> pScrollBar)
> {
>     if(pScrollBar != NULL)
>     {
>         pScrollBar->SetScrollPos(50);
>     }

>  CFormView::OnHScroll(nSBCode, nPos, pScrollBar);
> }

> I'm ignoring the messages and telling the scrollbar to position itself
> halfway in its range regardless of what message is received. This was
> just to zero in on a problem for debugging purposes. The scrollbar
> doesn't respond at all.

> Thanks for any help.

You say you are ignoring the message, but you are not.  You are passing
it on to the base class for default processing, which will reposition
the scroll bar normally.  Therefore the default processing immediately
overrides your setting.  Also note in the docs: "If you call the
base-class implementation of this function, that implementation will use
the parameters originally passed with the message and not the parameters
you supply to the function."

--
Scott McPhillips [VC++ MVP]



Tue, 13 Sep 2005 06:14:52 GMT  
 OnHScroll Problem

<snip>

Quote:
> > void CPDSynthView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar*
> > pScrollBar)
> > {
> >     if(pScrollBar != NULL)
> >     {
> >         pScrollBar->SetScrollPos(50);
> >     }

> >  CFormView::OnHScroll(nSBCode, nPos, pScrollBar);
> > }

<snip>

Quote:
> You say you are ignoring the message, but you are not.  You are
passing
> it on to the base class for default processing, which will reposition
> the scroll bar normally.  Therefore the default processing immediately
> overrides your setting.  Also note in the docs: "If you call the
> base-class implementation of this function, that implementation will
use
> the parameters originally passed with the message and not the
parameters
> you supply to the function."

But I've tried the function with and without calling the base-class
implementation. In either case, the position of the scrollbar is not
changed. I've even stepped through the code in the de{*filter*} to make sure
my OnHScroll function is being called, and it is. It's just that nothing
is happening as a result.


Tue, 13 Sep 2005 17:33:36 GMT  
 OnHScroll Problem

Apparently the problem was that I had not initialized the scrollbar
info. I assumed that the scrollbar would be set to some sensible default
value and thus useable. But it wasn't until I had set the scrollbar's
info that it worked.



Tue, 13 Sep 2005 23:07:19 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. OnHScroll problem.

2. Custom CSliderCtrl not responding to OnHScroll

3. CSliderCtrl & OnHScroll

4. CSlider.SetRange/OnHScroll range limits?

5. View gets drawn twice using OnHScroll

6. CSliderCtrl - how to catch OnHScroll

7. onHScroll --> GetScrollPos

8. overriding onHScroll

9. CSliderCtrl & OnHScroll

10. handling OnHScroll in the CSlider

11. OnHScroll() : why 2 called for 1 scroll (1click) ??

12. Custom CSliderCtrl not responding to OnHScroll

 

 
Powered by phpBB® Forum Software