News, Views, Rants and Raves About Technology and More

.NET : Smooth Scrolling Panel

with 4 comments

Windows raises ThumbTrack ScrollEvent while dragging Scrollbar. And if your System Visual Effects are optimized for performance, window contents are updated only when scollbar stops ( unlike browser)- that looks ugly and annoying.

To solve this I just substituted all SB_THUMBTRACK messeges with SB_THUMBPOSITION. Not very pretty, but works. The following code is in C#.

public class ScrollPanel : System.Windows.Forms.Panel
private const int WM_HSCROLL = 0x114;
private const int WM_VSCROLL = 0x115;

protected override void WndProc (ref Message m)
if ((m.Msg == WM_HSCROLL || m.Msg == WM_VSCROLL)
&& (((int)m.WParam & 0xFFFF) == 5))
m.WParam = (IntPtr)(((int)m.WParam & ~0xFFFF) | 4);
base.WndProc (ref m);


Written by Brajesh

January 10, 2006 at 2:56 pm

Posted in .net, Coding

4 Responses

Subscribe to comments with RSS.

  1. Can you please help me on your smooth scrolling example. or send me the example project ? basically im using compact framework and have panel with conrols on it… and i have a vScrollBar control and i want to make the scrolling smooth not choppy repaint. thanks a million


    February 8, 2008 at 8:58 pm

  2. Not that I’m impressed a lot, but this is a lot more than I expected when I stumpled upon a link on Digg telling that the info here is quite decent. Thanks.

    Ted Burrett

    April 24, 2009 at 11:20 am

  3. Thank you. So much.


    August 14, 2010 at 1:38 am

  4. […] 1) I found a little gem of code for how to make a control scroll smoothly. […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: