Question

When listening to the AdvancedCustomDraw event of a TTreeView event this way:

if Stage = cdPrePaint then begin
    // modify some Sender.Canvas properties and let it draw itself
end else if Stage = cdPostPaint then begin
    // draw 'something extra' using a separate TControlCanvas
    TControlCanvas.TextOut(SomeRect, 'Hello');
end;

... it seems that when I enable DoubleBuffered the control decides not to copy the 'something extra' to the offscreen buffer. This means that as long as I don't disturb the window in question, all is fine. When I do, the 'something extra' is only visible in random parts of the window.

What am I missing here?

Was it helpful?

Solution

Since your comment gave me carte blanche to suggest an alternative solution, here's what I would do:

  1. Stop using DoubleBuffered. It leads to lots of visual oddities in lots of controls. I personally avoid it like the plague.
  2. Solve your flickering problem by adding the WS_EX_COMPOSITED extended window style to your control. This window style can be a bit of a performance drag and I'd recommend that you only add this during the sizing loop, which is when you need it. I describe how to do that in my answer here: TLabel and TGroupbox Captions Flicker on Resize.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top