Skip to content

Commit a53caca

Browse files
committed
Create Suspend/ResumeDrawing control extensions
1 parent 4d1631d commit a53caca

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

src/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ namespace BizHawk.Client.EmuHawk
2323
{
2424
public static class ControlExtensions
2525
{
26+
private const int WM_SETREDRAW = 0x000B;
27+
2628
/// <exception cref="ArgumentException"><typeparamref name="T"/> does not inherit <see cref="Enum"/></exception>
2729
public static void PopulateFromEnum<T>(this ComboBox box, T enumVal)
2830
where T : Enum
@@ -199,6 +201,22 @@ public static CheckState ToCheckState(this bool? tristate)
199201
false => CheckState.Unchecked,
200202
null => CheckState.Indeterminate,
201203
};
204+
205+
public static void SuspendDrawing(this Control control)
206+
{
207+
if (!OSTailoredCode.IsUnixHost)
208+
{
209+
WmImports.SendMessageW(control.Handle, WM_SETREDRAW, (IntPtr) 0, IntPtr.Zero);
210+
}
211+
}
212+
213+
public static void ResumeDrawing(this Control control)
214+
{
215+
if (!OSTailoredCode.IsUnixHost)
216+
{
217+
WmImports.SendMessageW(control.Handle, WM_SETREDRAW, (IntPtr) 1, IntPtr.Zero);
218+
}
219+
}
202220
}
203221

204222
public static class ListViewExtensions

src/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -873,12 +873,7 @@ private void viewer_MouseDown(object sender, MouseEventArgs e)
873873
private void Freeze()
874874
{
875875
groupFreeze.SuspendLayout();
876-
877-
if (!OSTailoredCode.IsUnixHost)
878-
{
879-
// WM_SETREDRAW false
880-
WmImports.SendMessageW(groupFreeze.Handle, 11, (IntPtr)0, IntPtr.Zero);
881-
}
876+
groupFreeze.SuspendDrawing();
882877

883878
var tp = tabctrlDetails.SelectedTab;
884879

@@ -895,12 +890,7 @@ private void Freeze()
895890
if (tp == tpOBJ) groupFreeze.Text = "Freeze - OBJ";
896891

897892
groupFreeze.ResumeLayout();
898-
899-
if (!OSTailoredCode.IsUnixHost)
900-
{
901-
// WM_SETREDRAW true
902-
WmImports.SendMessageW(groupFreeze.Handle, 11, (IntPtr)1, IntPtr.Zero);
903-
}
893+
groupFreeze.ResumeDrawing();
904894

905895
groupFreeze.Refresh();
906896
}

0 commit comments

Comments
 (0)