Delphi IDE - 如何使禁用的工具栏按钮灰度化?
像这样的接缝只适用于真正的 Delphi 极客。
这就是它的样子(抱歉,无法发布图片)
Delphi IDE 丑陋的工具栏
(来源:piccy.info)
出了什么问题 - 禁用的 Delphi IDE 工具栏和菜单按钮是丑陋的黑白图像。
我想做的 - 让它们看起来是灰度的。
怎么做?我做了一些研究。主要问题在虚拟 TCustomImageList.DoDraw
方法中。当参数 Enabled = False
时,它会绘制丑陋的东西(请参阅屏幕截图上的禁用按钮)。我为此函数创建了自己的覆盖,当 Enabled = False
时,它会绘制灰度图像。
现在我想用我自己的替换默认的 DoDraw
< /em> 在 IDE 中(使用设计时包):
- 我发现单元 ImgList 是在 bds.exe 中编译的,因此在
rtlXXX.bpl
中修补此函数的技巧不会工作。 - 搜索函数的主体内容没有给出结果。看起来
DoDraw
的 bds.exe 实现(我正在谈论机器代码)有点不同。
关于如何实现这一点有什么建议或想法吗?作为运行时代码修补的基本示例,我采用了 Andy 的 Midas Speed Fix:FindMethodPtr、HookProc、UnhookProc
Seams like this one is for real Delphi geeks only.
This is how it looks (sorry, can't post images)
Delphi IDE ugly toolbar
(source: piccy.info)
What's wrong - disabled Delphi IDE toolbar and menu buttons are ugly black/white images.
What I want to do - make them look gray-scaled.
How? I made some research. Main problem in virtual TCustomImageList.DoDraw
method. When paramater Enabled = False
it paints ugly things (see disabled buttons on screenshot). I created my own override for this function and it paints gray-scaled images when Enabled = False
Now I want to replace default DoDraw
with my own in IDE (using design-time package):
- I figured out that unit ImgList is compiled-in bds.exe, so trick with patching this function in
rtlXXX.bpl
will not work. - Searching for function's body content gave no result. Looks like bds.exe's implementation (I'm talikng about machine codes) of
DoDraw
is a bit different.
Any suggestions or ideas of how can I make this possible? As base example of runtime code patching I took Andy's Midas Speed Fix: FindMethodPtr
, HookProc
, UnhookProc
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我做到了:)感谢所有参与或查看此问题的人!
这就是我的 IDE 现在的样子:
修复工具栏 http://blog.frantic。 im/wp-content/uploads/2009/11/delphi-ide-after.PNG
我刚刚搞砸了
vclXXX.pbl
,我的错。来源可以在此处找到。必须启用渐变工具栏才能使其工作。如果您有兴趣进一步发展这个想法 - 请阅读此主题I made it :) Thanks to everyone who participated or viewed this question!
This is how my IDE looks now:
Fixed toolbar http://blog.frantic.im/wp-content/uploads/2009/11/delphi-ide-after.PNG
I just messed up with
vclXXX.pbl
, my fault. Sources can be found here. Gradient toolbars must be enabled to make it work. If you are interested in further development of this idea - read this topic也许我对这个问题的理解很差,但如果您只想重写 DoDraw 函数,为什么不创建自己的继承自 TCustomImageList 的组件,重写所需的函数,以便它执行您想要的操作并将其注册到 IDE 中?
Maybe I'm understanding the problem badly but if you just want to override the DoDraw function why don't you just create your own component that inherits from TCustomImageList, override the desired function so that it does what you want and register it into the IDE?
如果您不想制作自己的重写组件,可以直接在[DelphiPath]\source\Win32\vcl\ImgList.pas中更改实现。
但这确实不是一个好办法。
If you don't want to make your own overriden components, you can change the realization directly in [DelphiPath]\source\Win32\vcl\ImgList.pas.
But it is really not a good way.
我一直不喜欢 Delphi 从启用图像创建默认禁用图像的方式。这不仅体现在 IDE 中,而且会持续到您正在开发的应用程序中。应用程序中禁用的图像看起来同样糟糕。
我过去曾试图弄清楚 Delphi 做了什么来导出禁用的图像并在此基础上进行构建。但它仍然在我的“要做的事情”清单上来完成它。
尽管如此,这些是我不久前遇到的一些关于 Delphi“故障”的文章,可能对您有帮助,也可能没有帮助:
禁用菜单项中难以区分的灰色斑点,作者:Vladimir S.
MenuImgList.pas
修复Delphi 5 中的按钮绘制故障
修复 Delphi 4 中的菜单绘制故障
I've always disliked the way Delphi creates default disabled images from enabled one. This not only manifests itself in the IDE, but it does persist down to the application you're developing. The disabled images in your application look just as bad.
I have in the past tried to figure out what Delphi did to derive the disabled images and build on that. But it still is on my "things to do" list to finish that off.
None-the-less, these are some articles about the Delphi "glitch" that I encountered quite a while ago that may or may not help you:
Indistinguishable gray blobs in disabled menu items, by Vladimir S.
MenuImgList.pas
Fixing a Buttons Drawing Glitch in Delphi 5
Fixing a Menu Drawing Glitch in Delphi 4