From 3c4d00baa46b0d759b279c48c8236d85d417e72d Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Mon, 6 Apr 2026 22:42:00 -0400 Subject: [PATCH] fix: suppress WM_ERASEBKGND to prevent drawing list flicker on quantity change ListBox is a native Win32 control so ControlStyles.OptimizedDoubleBuffer had no effect. The erase-then-redraw cycle on each Invalidate() caused visible flashing. Suppressing WM_ERASEBKGND is safe because OnDrawItem already fills the complete item bounds. Co-Authored-By: Claude Opus 4.6 (1M context) --- OpenNest/Controls/DrawingListBox.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/OpenNest/Controls/DrawingListBox.cs b/OpenNest/Controls/DrawingListBox.cs index 9982b16..3ec6407 100644 --- a/OpenNest/Controls/DrawingListBox.cs +++ b/OpenNest/Controls/DrawingListBox.cs @@ -8,16 +8,14 @@ namespace OpenNest.Controls public class DrawingListBox : ListBox { + private const int WM_ERASEBKGND = 0x0014; + private readonly Size imageSize; private readonly Font nameFont; private Point lastClickLocation; public DrawingListBox() { - SetStyle( - ControlStyles.AllPaintingInWmPaint | - ControlStyles.OptimizedDoubleBuffer, true); - DrawMode = DrawMode.OwnerDrawFixed; ItemHeight = 85; @@ -149,6 +147,16 @@ namespace OpenNest.Controls base.OnMouseDown(e); lastClickLocation = e.Location; } + + protected override void WndProc(ref Message m) + { + if (m.Msg == WM_ERASEBKGND) + { + m.Result = (IntPtr)1; + return; + } + base.WndProc(ref m); + } } public static class PointExtensions