简体   繁体   English

TToolbar与TForm.DoubleBuffered不兼容?

[英]TToolbar incompatible with TForm.DoubleBuffered?

I am using Delphi XE3. 我正在使用Delphi XE3。
When I create a new VCL project and drop a TToolbar on it, everything works fine - except when I activate Form1.DoubleBuffered . 当我创建一个新的VCL项目并在其上放一个TToolbar时,一切正常 - 除非我激活Form1.DoubleBuffered
From that moment on, drawing of the toolbar is broken - in designtime, it's either black, transparent, or parts of the IDE (statusbar, toolbar, etc.) are copied into it. 从那一刻起,工具栏的绘制就被打破了 - 在设计时,它是黑色,透明或IDE的一部分(状态栏,工具栏等)被复制到其中。 It changes between these options when I click on it and when I change to source code (F12) and back. 当我点击它时以及当我更改为源代码(F12)并返回时,它会在这些选项之间发生变化。
In runtime, it's always black. 在运行时,它总是黑色的。

With DrawingStyle=dsGradient , everything works as expected. 使用DrawingStyle=dsGradient ,一切都按预期工作。 Switching back to dsNormal breaks it again. 切换回dsNormal再次打破它。

Deactivating Form1.DoubleBuffered repairs it. 停用Form1.DoubleBuffered修复它。

Any hints how to work around that issue? 任何提示如何解决该问题?

As reported in this article, When not to use DoubleBuffered , some controls like TToolBar and TRichEdit don't work well with the DoubleBuffered property set to true. 正如本文所述, When not to use DoubleBuffered ,某些控件(如TToolBarTRichEditDoubleBuffered属性设置为true时效果DoubleBuffered

The reason be be found in documentation, TWinControl.DoubleBuffered , where some WinControls can't draw themselves on a temporary bitmap (as happens when DoubleBuffered is true). 原因可以在文档TWinControl.DoubleBuffered找到,其中一些WinControls无法在临时位图上绘制自己(就像DoubleBuffered为true时DoubleBuffered )。

One workaround can be to put the TToolBar on a TPanel . 一种解决方法是将TToolBar放在TPanel

In my opinion the solution is to set TForm.DoubleBuffered to False . 在我看来,解决方案是将TForm.DoubleBuffered设置为False Using a value of True causes all sorts of other problems. 使用值True会导致各种其他问题。 This property worked reasonably well before XP themes, but since their arrival, using TForm.DoubleBuffered has not been viable, in my view. 这个属性在XP主题之前运行得相当好,但是自从他们到来之后,在我看来,使用TForm.DoubleBuffered并不可行。

In addition to the problems you have encountered, I've come across lots of painting flaws when using the Windows Basic theme. 除了遇到的问题,我在使用Windows Basic主题时遇到了很多绘画漏洞。 I know that's not mainstream, but I happen to see that a lot with remote access. 我知道这不是主流,但我碰巧看到很多远程访问。 And there's more. 而且还有更多。 When you double buffer a form you stop the theme animation from working. 双重缓冲表单时,停止主题动画的工作。 For example, a default button pulses to indicate that it is the default button. 例如,默认按钮会发出脉冲以指示它是默认按钮。

If you get resize flickering without double buffering the form, use the ideas from my answer to another question . 如果您在没有双重缓冲表单的情况下调整大小闪烁,请使用我对其他问题的回答中想法 From the comments it seems that the flickering you wish to combat is in a paint box. 从评论看来,你想要打击的闪烁似乎是在一个颜料盒中。 I obviously don't know the details, but my experience and instincts say that you should be able to deal quite easily with that flickering at a local level. 我显然不知道细节,但我的经验和直觉说你应该能够很容易地处理当地的闪烁。 There surely should be no need for the global form wide double buffering. 肯定不需要全局形式的双重缓冲。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM