DoubleBufferPanel: Panel with double buffer and utility functions.

This commit is contained in:
2017-02-05 01:07:58 +01:00
parent 1fbb85c101
commit 11dab2e63e
4 changed files with 70 additions and 15 deletions

41
DoubleBufferPanel.cs Normal file
View File

@@ -0,0 +1,41 @@
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace CsvView
{
public class DoubleBufferPanel : Panel
{
public DoubleBufferPanel()
{
DoubleBuffered = true;
SetStyle(ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.ResizeRedraw |
ControlStyles.ContainerControl |
ControlStyles.OptimizedDoubleBuffer |
ControlStyles.SupportsTransparentBackColor
, true);
}
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SendMessage(IntPtr hWnd, Int32 wMsg, bool wParam, Int32 lParam);
private const int WM_SetRedraw = 0XB;
public void SuspendDrawing()
{
SuspendLayout();
SendMessage(Handle, WM_SetRedraw, false, 0);
}
public void ResumeDrawing()
{
ResumeLayout(true);
SendMessage(Handle, WM_SetRedraw, true, 0);
Refresh();
}
}
}