From: Ririko Horvath on
Hello,

The contents of a window's client area gets garbled by scrolling when
'ScrollWindow' or 'ScrollWindowEx' followed by UpdateWindowis used to
scroll the contents of a window's client area. Does anyone know what is an
easiest way to overcome this problem.

Thank You!


From: Scott McPhillips [MVP] on
Ririko Horvath wrote:
> Hello,
>
> The contents of a window's client area gets garbled by scrolling when
> 'ScrollWindow' or 'ScrollWindowEx' followed by UpdateWindowis used to
> scroll the contents of a window's client area. Does anyone know what is an
> easiest way to overcome this problem.
>
> Thank You!
>
>

ScrollWindow copies the existing pixels to their new position and
invalidates only the thin strip at the edge that needs new pixels. So
UpdateWindow clips painting to the new strip because it is the only part
that has been invalidated.

If you need to repaint more than the new strip after a scroll then you
should add a call to Invalidate() in OnHScroll or OnVScroll. This will
change the clipping region to the entire client area of the window.

--
Scott McPhillips [VC++ MVP]

From: Ririko Horvath on
I called Invalidate() (tried passing both true and false) from OnHScroll.
Unfortunately it stopped the scrolling of the window's client area. The code
I am using is as follows:

// from OnHScroll
if (si.nPos != xPos) {
m_ListBox.ScrollWindow(xPos - si.nPos, 0, NULL,NULL);
Invalidate(true);
/* also tried
m_ListBox.Invalidate(true);
*/
}

Can you tell me waht I am doing wrong?

Thank You!

"Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp> wrote in message
news:eoifWCnGFHA.2752(a)TK2MSFTNGP12.phx.gbl...
> Ririko Horvath wrote:
> > Hello,
> >
> > The contents of a window's client area gets garbled by scrolling
when
> > 'ScrollWindow' or 'ScrollWindowEx' followed by UpdateWindowis used to
> > scroll the contents of a window's client area. Does anyone know what is
an
> > easiest way to overcome this problem.
> >
> > Thank You!
> >
> >
>
> ScrollWindow copies the existing pixels to their new position and
> invalidates only the thin strip at the edge that needs new pixels. So
> UpdateWindow clips painting to the new strip because it is the only part
> that has been invalidated.
>
> If you need to repaint more than the new strip after a scroll then you
> should add a call to Invalidate() in OnHScroll or OnVScroll. This will
> change the clipping region to the entire client area of the window.
>
> --
> Scott McPhillips [VC++ MVP]
>


From: Scott McPhillips [MVP] on
Ririko Horvath wrote:

> I called Invalidate() (tried passing both true and false) from OnHScroll.
> Unfortunately it stopped the scrolling of the window's client area. The code
> I am using is as follows:
>
> // from OnHScroll
> if (si.nPos != xPos) {
> m_ListBox.ScrollWindow(xPos - si.nPos, 0, NULL,NULL);
> Invalidate(true);
> /* also tried
> m_ListBox.Invalidate(true);
> */
> }
>
> Can you tell me waht I am doing wrong?
>
> Thank You!

I assume m_ListBox is a CListBox? What you seem to be doing here is
messing with the painted image of the list box without informing the
list box code of the desired new position. So it doesn't know what you
want where. You should not expect the list box to respond in any way to
the parent's scroll bars.

--
Scott McPhillips [VC++ MVP]