I’m using a Matrix to set a transformation on my Graphics object during OnPaint. I would like the scrollbars to translate the matrix when scrolled; something like this in OnScroll:
float offset = se.NewValue - se.OldValue;
if (offset == 0)
{
return;
}
if (se.ScrollOrientation == ScrollOrientation.HorizontalScroll)
{
this.TransformMatrix.Translate(-offset, 0);
}
else
{
this.TransformMatrix.Translate(0, -offset);
}
I’m pretty sure that both WM_VSCROLL and WM_HSCROLL send a WM_PAINT because the control is redrawn without me actually calling Refresh(). I find that this painting isn’t very fluid and is jittery and doesn’t draw with the right transformation it seems. Should I intercept the WM_V/HSCROLL messages and manually set the scrollbar’s properties (like position etc) with SetScrollInfo? If not, what should I do?
I ended up catching
WM_V/HSROLLand doing the painting on my own. It works great!Here’s what I’m using if anyone wants it: