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) <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user