Avoid painting over nested controls

Posted by Cobus Kruger on Stack Overflow See other posts from Stack Overflow or by Cobus Kruger
Published on 2010-03-24T14:46:53Z Indexed on 2010/03/25 10:43 UTC
Read the original article Hit count: 435

Filed under:
|
|

I am writing a toolbar-style control and use the ThemeServices unit to paint the background required by the toolbar. Like so:

ThemeServices.DrawElement(Canvas.Handle, 
  ThemeServices.GetElementDetails(trRebarRoot), ARect);

I then drop child controls onto the toolbar and voila - instant toolbar. Except that every now and again I notice that the nested (child) controls don't repaint as well. So my control paints its background and the child controls disappear until you move the mouse over them.

Some of the edit controls show their client area (no border) and some of them are just gone altogether.

This happens mostly when I place a window from another application over the toolbar and move it away.

I keep thinking this has to be very easy to cure, that perhaps I'm somehow preventing the paint message from reaching the child controls, or missing an override but I have been unable to figure it out.

© Stack Overflow or respective owner

Related posts about delphi

Related posts about custom-controls