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

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

问题描述

当我的工具栏图标的相关操作将其选中"属性设置为 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 2009 的 Delphi 4 程序员,我对 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:弹出菜单:已检查"项目,图标不再显示为凹陷? Peter Beyond 贡献了他的专业知识,让我意识到我根本不想更改为 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 颜色图.在此模式下,选中的项目将被突出显示.这就是我真正想要的 - 突出显示选中的项目.我以 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.

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

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