1

I have main Panel and Auto Scroll=true, and all controls are placed on main panel. Functionality works fine but when I click on any control or scroll down or up so it start flickering for a second each time I click or Scroll,

I also set

 DoubleBuffered = true; 

but it is not working for me.

could any body please suggest me solution or new code which can help me I alrasy spent 2 days on this problem. thanks in advance.

Saeed Khan
  • 537
  • 2
  • 12
  • 27
  • possible duplicate of [How to fix the flickering in User controls](http://stackoverflow.com/questions/2612487/how-to-fix-the-flickering-in-user-controls) – Hans Passant Apr 15 '13 at 12:57

1 Answers1

0

You can try to put this into your forms class:

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))
    {
        // Change SB_THUMBTRACK to SB_THUMBPOSITION
        m.WParam = (IntPtr)(((int)m.WParam & ~0xFFFF) | 4);
    }
    base.WndProc (ref m);
}

You could also add this to your forms class constructor:

SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);

Im using windows 8, and i dont get flicker from a panel with AutoScroll=true. but the above methods should solve the flicker.

string.Empty
  • 10,393
  • 4
  • 39
  • 67