如何在Delphi中的TabControl中更改活动TAB的颜色 [英] How to change the color of active TAB in a TabControl, in Delphi

查看:143
本文介绍了如何在Delphi中的TabControl中更改活动TAB的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在TabControl中(在FireMonkey上)更改活动TAB的颜色,如下所示?

How to change the color of active TAB in a TabControl (on FireMonkey) as shown below?

推荐答案

有两种方法可以实现此目的.

There are 2 ways to make this happen.

1)第一个选项是您可以从 TStyleBook为 TabControl 创建 CustomStyle (样式设计器).

1) First option is you can create CustomStyle for TabControl from TStyleBook (Style Designer).

然后,您可以添加要在自定义设计中使用的任何内容(对于许多形状和颜色,建议使用 TRectangle ).

Then you can add whatever you want to use in your custom design (TRectangle is recommmended for many shape and colors).

2)我更喜欢使用第二种方式.将 TTabControl TabPosition 设置为 ,然后在要在表单中添加标签的位置添加 TGridPanelLayout .之后,为标签页数设置TGridPanelLayout的列数.

2) I prefer to use second way for it. Set the TTabControl's TabPosition to None, then add a TGridPanelLayout to where you want to add tabs in your form. After that, set your TGridPanelLayout's column count for your tab count.

现在,您需要知道每个选项卡框都应该相同.在第一列中放置 矩形 ,然后将 Align 设置为 Client (所有颜色和内部组件均取决于您的选择).

Now you need to know that your each tab box should be same. Drop a TRectangle for first column then set Align to Client (All colors and inner components are depends on your choice).

确保您的 TRectangle 组件 HitTest 参数为 true 和内部组件的 HitTest 参数为 false .

Be sure that your TRectangle components HitTest parameter is true and inner components' HitTest parameter is false.

您还可以处理 OnClick 事件中的选项卡选择.为每个TRectangle(用于选项卡)设置一个Tag,然后将所有选项卡连接到相同的OnClick事件.然后,您将获得发件人的标签,并从标签中设置 TabControl1.ActiveTab .

Also you can handle your tab selections from OnClick event. Set each TRectangle (for tab) a Tag then connect all tabs to same OnClick event. Then you get Sender's Tag and set your TabControl1.ActiveTab from your Tag.

这篇关于如何在Delphi中的TabControl中更改活动TAB的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆