110,534
社区成员
发帖
与我相关
我的任务
分享
/// <summary>
/// 双缓冲 panel
/// </summary>
public class PanelEx : Panel
{
public PanelEx()
{
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint, true);
UpdateStyles();
}
}
/// <summary>
/// 双缓冲 PictureBox
/// </summary>
public class PictureBoxEx : PictureBox
{
public PictureBoxEx()
{
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint, true);
UpdateStyles();
}
}
/// <summary>
/// 双缓冲 TreeView
/// </summary>
public class TreeViewEx : TreeView
{
protected override void OnHandleCreated(EventArgs e)
{
SendMessage(this.Handle, TVM_SETEXTENDEDSTYLE, (IntPtr)TVS_EX_DOUBLEBUFFER, (IntPtr)TVS_EX_DOUBLEBUFFER);
base.OnHandleCreated(e);
}
private const int TVM_SETEXTENDEDSTYLE = 0x1100 + 44;
private const int TVM_GETEXTENDEDSTYLE = 0x1100 + 45;
private const int TVS_EX_DOUBLEBUFFER = 0x0004;
[DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);
}
/// <summary>
/// 双缓冲 ListView
/// </summary>
public class ListViewEx : ListView
{
public ListViewEx()
{
SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
UpdateStyles();
}
}