-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathSuspendDrawing.cs
32 lines (29 loc) · 1020 Bytes
/
SuspendDrawing.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace hexer
{
public class SuspendDrawing : IDisposable
{
private const int WM_SETREDRAW = 0x000B;
private readonly Control control;
private readonly NativeWindow window;
public SuspendDrawing(Control control)
{
this.control = control;
var msgSuspendUpdate = Message.Create(this.control.Handle, WM_SETREDRAW, IntPtr.Zero, IntPtr.Zero);
window = NativeWindow.FromHandle(this.control.Handle);
window.DefWndProc(ref msgSuspendUpdate);
}
public void Dispose()
{
var wparam = new IntPtr(1); // Create a C "true" boolean as an IntPtr
var msgResumeUpdate = Message.Create(control.Handle, WM_SETREDRAW, wparam, IntPtr.Zero);
window.DefWndProc(ref msgResumeUpdate);
control.Invalidate();
}
}
}