I am assuming that TopFormmlcmpStatusPanel1
is of type TStatusBar
.
You do not send WM_PAINT
or WM_ERASEBKGND
messages. The system does that.
Your code:
TopFormmlcmpStatusPanel1.Invalidate;
will lead to a new paint cycle. When the message loop is next emptied, a paint cycle will be generated and the control will be re-painted.
Alternatively you might use:
TopFormmlcmpStatusPanel1.Refresh;
if you want the control to be re-painted immediately.
So, I guess your problem is more subtle than you think. My expectation is that your controls are drawn by the system using the system theme. And your attempts to change the colour simply cannot ever have any effect because the theme overrides the control's colour properties. Without an SSCCE, it is hard to be sure that this is the problem.
In the comments you state that your control is owner drawn. It is conceivable that your owner draw code has a fault. I am clearly in no position to comment on that code which I cannot observe. However, I would re-state the fact that the Invalidate
and Refresh
methods will both lead to a paint cycle.