using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace GeminiCricket
{
class DoubleBufferedPanel : Panel
{
public DoubleBufferedPanel()
{
this.DoubleBuffered = true;
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.Opaque, true);
this.UpdateStyles();
}
protected override void OnScroll(ScrollEventArgs se)
{
if (se.Type == ScrollEventType.First) LockWindowUpdate(this.Handle);
else if (se.Type == ScrollEventType.ThumbTrack || se.Type == ScrollEventType.ThumbPosition)
{
LockWindowUpdate(IntPtr.Zero);
this.Refresh();
LockWindowUpdate(this.Handle);
}
else
{
LockWindowUpdate(IntPtr.Zero);
this.Invalidate();
}
base.OnScroll(se);
}
// P/Invoke declarations
[DllImport("user32.dll")]
private static extern bool LockWindowUpdate(IntPtr hWnd);
}
}
|