aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/Tools/ControlManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ShiftOS.WinForms/Tools/ControlManager.cs')
-rw-r--r--ShiftOS.WinForms/Tools/ControlManager.cs19
1 files changed, 19 insertions, 0 deletions
diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs
index c5b073f..f9fb799 100644
--- a/ShiftOS.WinForms/Tools/ControlManager.cs
+++ b/ShiftOS.WinForms/Tools/ControlManager.cs
@@ -26,6 +26,7 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
+using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
@@ -37,6 +38,22 @@ namespace ShiftOS.WinForms.Tools
{
public static class ControlManager
{
+ [DllImport("user32.dll")]
+ public static extern int SendMessage(IntPtr hWnd, Int32 wMsg, bool wParam, Int32 lParam);
+
+ private const int WM_SETREDRAW = 11;
+
+ public static void SuspendDrawing(Control parent)
+ {
+ SendMessage(parent.Handle, WM_SETREDRAW, false, 0);
+ }
+
+ public static void ResumeDrawing(Control parent)
+ {
+ SendMessage(parent.Handle, WM_SETREDRAW, true, 0);
+ parent.Refresh();
+ }
+
public static void Close(this UserControl ctrl)
{
for (int i = 0; i < AppearanceManager.OpenForms.Count; i++)
@@ -157,6 +174,7 @@ namespace ShiftOS.WinForms.Tools
public static void SetupControl(Control ctrl)
{
+ SuspendDrawing(ctrl);
SetCursor(ctrl);
if (!(ctrl is MenuStrip) && !(ctrl is ToolStrip) && !(ctrl is StatusStrip) && !(ctrl is ContextMenuStrip))
{
@@ -225,6 +243,7 @@ namespace ShiftOS.WinForms.Tools
}
MakeDoubleBuffered(ctrl);
+ ResumeDrawing(ctrl);
}
public static void MakeDoubleBuffered(Control c)