![](/img/trans.png)
[英]Delphi tbsSeparator TToolButton on a non-themed TToolBar with Flat style has a vertical line in the middle - how to fix it?
[英]TToolBar paints incorrectly on non-themed Windows
最近引起我注意的是,我们的一个应用程序在非主题 Windows 上绘制不正确。
工具栏是由嵌套在 TToolbar 中的 TSpeedButtons 构建的,而 TToolbar 又位于页面控件中。
在主题 Windows 上,一切看起来都不错。 好吧,不是很好,但还可以。
然而,在非主题 Windows 上,按钮内出现奇怪的垂直线。
我四处搜寻,但找不到任何有关此类问题的报告。 (很可能只是我的搜索功夫很烂。)有人知道这个问题的描述,或者更好的是,一个修复?
TToolbar
的设计目的不是容纳TSpeedButtons
。 它旨在容纳TToolButtons
,这些按钮不仅可以放在TToolBar
上,而且还专门编写用于在栏上正确运行。
您遇到的问题(特别是按原样绘制分隔符)是因为您使用了不兼容的TSpeedButton
并用TToolButton
分隔符分隔它们。 TSpeedButton
在TPanel
上运行良好,而 IIRC 就是在 MS 在 ComCtl 中提供TToolBar/TToolButton
对之前设计的。
一个带有TToolButtons
和TPanel
TToolBar
TSpeedButtons
应该看看这是否解决了问题。
编辑:您的评论不太正确。 :)
将TToolBar.AllowTextButtons
设置为 True,然后将您想要更宽的按钮设置为tbsTextButton
样式。 如您所见,我使用了一个普通按钮、一个分隔符、一个文本按钮(带有文本和图像)、一个分隔符和另一个普通按钮。
正如 TOndrej 在评论中所说,当TSpeedButton.Flat
和.Transparent
都设置为 True 时会发生这种情况。 正如 David 发现的那样, TToolbar
还必须将.Flat
设置为 True 才能发生问题。
不需要更改 VCL 源代码的解决方法是将.Transparent
设置为 False。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.