TToolbar incompatible with TForm.DoubleBuffered?

I am using Delphi XE3.
When I create a new VCL project and drop the TToolbar on it, everything works fine - except when I activate Form1.DoubleBuffered .
From this moment, the drawing of the toolbar is broken - during development it is either black, transparent, or parts of the IDE (status bar, toolbar, etc.) is copied to it. It changes between these parameters when I click on it, and when I go to the source code (F12) and back.
At runtime, it is always black.

With DrawingStyle=dsGradient everything works as expected. Returning to dsNormal breaks it again.

Deactivating Form1.DoubleBuffered fixes it.

Any tips on how to get around this?

+7
source share
2 answers

In my opinion, the solution is to set TForm.DoubleBuffered to False . Using the True value causes all sorts of other problems. This property worked quite well in front of XP themes, but since they appeared using TForm.DoubleBuffered not been viable in my opinion.

In addition to the problems you encountered, I encountered many drawbacks to use when using the Windows Basic theme. I know this is not mainstream, but I often see this with remote access. And further. When you double the shape buffer, you stop working with theme animations. For example, the default button gives pulses to indicate that it is the default button.

If you get flickering size without double buffering the form, use the ideas from my answer to another question . From the comments it seems that the flicker you want to fight is in the paint. I obviously don’t know the details, but my experience and instincts say that you should deal with ease with this flicker locally. Of course, there should be no need for double double buffering in global form.

+4
source

As indicated in this article When not to use DoubleBuffered , some controls, such as TToolBar and TRichEdit , do not work with DoubleBuffered set to true.

The reason can be found in the TWinControl.DoubleBuffered documentation, where some WinControls cannot draw themselves on a temporary bitmap (as happens when DoubleBuffered true).

One workaround may be to put the TToolBar on a TPanel .

+4
source

All Articles