1,设定个别控件的双缓冲:
public static void SetDoubleBuffered(object obj)
{
Type type = obj.GetType();
PropertyInfo pi = type.GetProperty("DoubleBuffered",
BindingFlags.Instance | BindingFlags.NonPublic);
pi.SetValue(obj, true, null);
}
2,跳过系统消息
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000;
return cp;
}
}
3,整个form的双缓冲(基本没有啥用)
this.DoubleBuffered = true;//设置本窗体
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲
SetDoubleBuffered(PanelIndex);
SetDoubleBuffered(PanelControl);
4,跳过系统的信息
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x0014) // 禁掉清除背景消息
return;
if(m.Msg == 0xf)
return;
if (m.Msg == 0x88)
return;
base.WndProc(ref m);
}