fix: clear empty area below items in drawing list on resize

The WM_ERASEBKGND suppression from 3c4d00b left stale artifacts
in the non-item region when the control was resized. Fill only
the area below the last visible item so items still don't flicker.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-07 08:23:30 -04:00
parent 6bed736cf0
commit 11884e712d

View File

@@ -152,6 +152,20 @@ namespace OpenNest.Controls
{
if (m.Msg == WM_ERASEBKGND)
{
var itemBottom = 0;
if (Items.Count > 0)
{
var lastVisible = System.Math.Min(TopIndex + (ClientSize.Height / ItemHeight), Items.Count - 1);
itemBottom = GetItemRectangle(lastVisible).Bottom;
}
if (itemBottom < ClientSize.Height)
{
using var g = Graphics.FromHdc(m.WParam);
g.FillRectangle(Brushes.White, 0, itemBottom, ClientSize.Width, ClientSize.Height - itemBottom);
}
m.Result = (IntPtr)1;
return;
}