2

当以这种方式监听 TTreeView 事件的 AdvancedCustomDraw 事件时:

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;

...似乎当我启用 DoubleBuffered 时,控件决定不将“额外的东西”复制到屏幕外缓冲区。这意味着只要我不打扰有问题的窗户,一切都很好。当我这样做时,“额外的东西”仅在窗口的随机部分可见。

我在这里想念什么?

4

1 回答 1

4

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.
于 2013-02-02T21:31:08.440 回答