开发者

TToolBar paints incorrectly on non-themed Windows

It was recently brought to 开发者_JAVA百科my attention that one of our applications paints incorrectly on non-themed Windows.

Toolbar is built from TSpeedButtons nested in TToolbar which in turn lives inside a page control.

On themed Windows everything looks nice. Well, not nice, but ok.

TToolBar paints incorrectly on non-themed Windows

On non-themed Windows, however, weird vertical lines appear inside buttons.

TToolBar paints incorrectly on non-themed Windows

I've searched around but cannot find any report of such a problem. (Most probably just my search kung fu sucks.) Does anybody know of a description of this problem or, even better, a fix?


TToolbar isn't designed to hold TSpeedButtons. It's designed to hold TToolButtons, which are made to not only sit on a TToolBar, but are specially written to behave correctly on the bar.

The issue you're having (particularly with the separators being drawn the way they are) is because you're using the incompatible TSpeedButton and separating them with TToolButton separatorss. TSpeedButton works well on a TPanel, and IIRC were designed for just that prior to MS providing the TToolBar/TToolButton pair in ComCtl.

A quick test app with both a TToolBar with TToolButtons and a TPanel with TSpeedButtons should see if this solves the problem.

EDIT: Your comment isn't quite correct. :)

TToolBar paints incorrectly on non-themed Windows

Set the TToolBar.AllowTextButtons to True, and then set the button's you want wider to style tbsTextButton. As you can see, I've used a plain button, a separator, a text button (with text and image), a separator, and another plain button.


As TOndrej said in comments, this happens when TSpeedButton.Flat and .Transparent are both set to True. As David found out, TToolbar must also have .Flat set to True for the problem to occur.

A workaround that doesn't require changing the VCL source code is to set .Transparent to False.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜