如何使用Delphi实现高亮显示的工具栏图标? [英] How Can I Implement Highlighted Toolbar Icons With Delphi?

查看:169
本文介绍了如何使用Delphi实现高亮显示的工具栏图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们将关联的动作的checked属性设置为true时,我想突出显示我的工具栏图标。我想这样做的方式类似于Microsoft Office 2003,例如请参阅此图片中的粗体和对齐左图标:

I'd like to highlight my toolbar icons when their associated action has it's "checked" property set to true. I'd like to do it in a manner similar to how Microsoft Office 2003 did it, e.g. see the Bold and Align Left icons in this image:

图像以其周围的方框绘制,背景已更改为橙色。

The image is drawn with a box around it and the background has been changed to orange.

如何使用Delphi 2009实现?

How could I implement this using Delphi 2009?

作为一个奖励,还有一种方法可以在相关项目菜单中的图标做同样的事情?例如如下面的标尺和标记条目:

As a bonus, is there also a way to do the same thing with the icon in the menu for the associated item? e.g. as below with the Ruler and Markup entries:

跟进:

谢谢Andreas什么是我的问题的简单而正确的答案。作为Delphi 4程序员转换为Delphi 2009,我对Delphi 5到7添加的VCL不够熟悉,所以TActionManager,TActionToolbar及其工作原理不在我的Delphi词汇表中。这是基于Delphi使用类似于Microsoft O / S主题的风格的能力。

Thank you Andreas, for what is a simple and correct answer to my question. As a Delphi 4 programmer converted to Delphi 2009, I was not familiar enough with the VCL additions of Delphi 5 to 7, so the TActionManager, TActionToolbar and their workings were not in my Delphi vocabulary. And this is based on Delphi's ability to use a style that is akin to a Microsoft O/S's theme.

然而,随着你的回答和一些使用它的研究,我确认我不想这样做。一个照亮的Embarcadero线程re:弹出菜单:带有图标的已检查项目不再显示为凹陷?与彼得在下面贡献他的专业知识,让我意识到,我不想改变到XP主题,因为这将对Vista和Windows 7用户做的baaaaad的东西,把他们带回到青铜器时代

However, with your answer, and a bit of research using it, I confirm that I do not want to do this in this manner. An illuminating Embarcadero thread re: Popup menus: "Checked" items with icon no longer shown as sunken? with Peter Below contributing his expertise, made me realize that I don't want to change to the XP theme at all, since that will do baaaaad things to Vista and Windows 7 users, taking them back to the Bronze Age.

这里真正的罪魁祸首是,O / S主题有一些要你尊重的东西。德尔福试图遵循规则。我可以回到XP,XP风格/主题和XP Color Map。在这种模式下,检查的项目将被遮挡。这真的是我想要的 - 突出显示检查项目。我以Office 2003为例,因为这是我想要的那种低调。但是我真的不想完全改变主题,并强制我的程序全新的面貌。对于Vista和Windows 7用户来说,这样做会使事情变得不自然。

The true culprit here is that there are certain things that the O/S themes want you to respect. Delphi tries to follow the rules. I can go back to XP, the XP style/theme, and the XP Color Map. In this mode, checked items will be hilighted. And this is really all I wanted - to highlight the checked items. I used Office 2003 as an example, because it was the sort of hilighting I wanted. But I really didn't want to entirely change themes and force an entire new look on my program. It would especially make things look unnatural for Vista and Windows 7 users.

如果我可以使用另一套将在对象被检查时应用的图像...但是没有CheckedImages属性。或者如果检查图像(例如,像禁用的图像获得其启用的图像的灰度版本),则以编程方式或自动修改图像的方式。

What would be ideal is if I could have another set of Images that would apply when the object is Checked ... but there is not a "CheckedImages" property. Or a way of programmatically or automatically modifying the image if it is checked (e.g. like disabled images get a grayscale version of their enabled image).

如果有任何方法可以实现这个或者其他可能同样顺利的工作,我还是不介意听任何人,而不改变我的程序的整体外观。

I still wouldn't mind hearing from anyone if there are any ways to implement this or something else that might work equally well, without changing the entire look of my program.

推荐答案

还可以使用普通的 TToolBar DrawingStyle 设置为 dsGradient ,我刚刚发现。

One can also use an ordinary TToolBar, with DrawingStyle set to dsGradient, I just found out.

具有dsGradient的示例工具栏作为DrawingStyle http://privat.rejbrand.se/toolbar2.png

这篇关于如何使用Delphi实现高亮显示的工具栏图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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