ScrollWindowEx (user32)
Last changed: -212.242.149.175

.
Summary

C# Signature:

[DllImport("user32.dll")]
static extern int ScrollWindowEx(IntPtr hWnd, int dx, int dy, IntPtr prcScroll,
   IntPtr prcClip, IntPtr hrgnUpdate, IntPtr prcUpdate, uint flags);

User-Defined Types:

None.

Flags:

/// <summary>
/// Scroll children within *lprcScroll.
/// </summary>
public const uint SW_SCROLLCHILDREN = 0x0001;
/// <summary>
/// Invalidate after scrolling.
/// </summary>
public const uint SW_INVALIDATE        = 0x0002;
/// <summary>
/// If SW_INVALIDATE, don't send WM_ERASEBACKGROUND.
/// </summary>
public const uint SW_ERASE            = 0x0004;
/// <summary>
/// Use smooth scrolling.
/// </summary>
public const uint SW_SMOOTHSCROLL    = 0x0010;

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

      [DllImport( "user32.dll" )]
      static extern int ScrollWindowEx(
     IntPtr hWnd,
     int dx,
     int dy,
     IntPtr prcScroll,
     IntPtr prcClip,
     IntPtr hrgnUpdate,
     IntPtr prcUpdate,
     uint flags );

      unsafe private void hScrollBar1_Scroll( object sender, ScrollEventArgs e )
      {
     int ScrollDelta;
     RECT ScrollRect = new RECT();

     ScrollDelta = FPosition - e.NewValue; // FPosition is the previous scrollbar position
     FPosition = e.NewValue;
     if ( ScrollDelta != 0 )
     {
        ScrollRect.Left = 100;
        ScrollRect.Top = 50;
        ScrollRect.Right = this.Width - SystemInformation.VerticalScrollBarWidth;
        ScrollRect.Bottom = this.Height - 50;
        IntPtr RectPointer = new IntPtr( &ScrollRect );
        ScrollWindowEx( this.Handle, ScrollDelta, 0, RectPointer, RectPointer, (IntPtr)null, (IntPtr)0, 2 );
     }
      }

Alternative Managed API:

Do you know one? Please contribute it!

Documentation