Delphi-更改活动页面的选项卡颜色,并在单击另一个选项卡后将其重置 [英] Delphi - Changing active page's tab color and having it reset after clicking on another tab

查看:153
本文介绍了Delphi-更改活动页面的选项卡颜色,并在单击另一个选项卡后将其重置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,在我编写的程序中,我正在使用带有多个选项卡的TPageControl组件.我想更改当前是PageControl上活动页面的工作表的选项卡的颜色,然后在单击另一页后重置颜色(然后该选项卡将由于活动页面而改变,依此类推...),以使导航页面控件更加容易.但是我不确定该怎么做?我确实尝试过使用页面控件的OnChange过程和类似这样的代码(我知道这是非常错误的,但是我用尽了想法和Google搜索.无论如何,它还是行不通的.):

So in the program I'm writing, I'm using a TPageControl component with multiple tab sheets. I want to change the color of the tab of the sheet that is currently the active page on the PageControl and then have the color be reset after clicking on another page (then that tab will change due to it being the active page and so on...), to make navigating the page control a bit easier. But I'm not sure how to do it? I did try using the OnChange procedure of the page control and some code like this (I know it's horribly wrong but I ran out of ideas and google searches. It didn't work anyway.):

with pgcTabs.ActivePage do
begin 
brush.color:=clBlue;
font.color:=clWhite;
end; 

提前感谢您的帮助!
亲切的问候
PrimeBeat

Thanks in advance for the help!
Kind Regards
PrimeBeat

推荐答案

您不能.除了使用 TTabSheet.Highlighted 外,您无法控制标签的显示方式.

You can't. Apart from using TTabSheet.Highlighted you have no control over how the tabs are displayed.

或者像大多数其他控件一样,您必须自己完全绘制它:将 TPageControl.OwnerDraw 设置为 true ,然后使用 OnDrawTab 事件以绘制您想要的任何内容.它应该与 TTabControl.OnDrawTab (请参阅答案)相同.自己绘画所有东西的缺点(双关语)通常是要做的所有额外工作:检查尺寸,解释加速键,尊重系统颜色和设置(即LTR)...

Or you have to fully draw it yourself, as usual as for most other controls: set TPageControl.OwnerDraw to true, then use the OnDrawTab event to paint whatever you want to. It should be identical to TTabControl.OnDrawTab (see answer). The drawbacks (pun intended) of painting everything yourself is usually all the extra work to do: checking dimensions, interpreting accelerator keys, respecting system colors and settings (i.e. LTR)...

我认为只是添加颜色"与默认情况下控件已具有所有优点和功能的绘画方式相比,它几乎没有价值.考虑色盲:那些人可能宁愿有问题.

In my opinion "just adding a color" has little to no value compared to how the control by default paints already with all its advantages and features. Consider color blindness: those people might rather have problems.

这篇关于Delphi-更改活动页面的选项卡颜色,并在单击另一个选项卡后将其重置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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