While looking at ways of improving the UI of a dialog in an application, I wanted to display some status text in a
ListBox control that was empty. The default Windows Forms
ListBox (which uses the underlying native Win32 control) doesn't support this, but with a little effort we can extend the control.
Control receives either the
WM_ERASEBKGND messages, it will check to see if the
ControlStyles.UserPaint style is set. If set then the
WM_PAINT message will cause the
Paint event to be raised, and for
PaintBackground event - but only if the the
AllPaintingInWmPaint style is not set.