修改VCL组件

发布于 2024-11-30 02:37:41 字数 421 浏览 2 评论 0原文

可能的重复:
替换delphi中的组件类

有人有修改VCL组件的技巧吗并使它们成为 IDE 中相对默认的?这意味着不一定是它们的后代,而是在后代对象中似乎不允许此类事情的地方更改功能。如果它们可以用来代替标准组件,那也是一个好处。

例如,我想做的一件事是在 TButton 上进行 alpha 混合鼠标悬停。我注意到没有 OwnerDraw 事件,并且修改按钮绘制方式的代码似乎不在我可以覆盖的位置。有什么建议,或者我是否必须将 TButton 及其所有祖先从 VCL 代码中删除并直接修改它?

Possible Duplicate:
Replacing a component class in delphi

Does anyone have any tips for modifying the VCL components and making them so they are relatively default within the IDE? This means not necessarily descending from them, but changing functionality in places that don't seem to allow such things in a descendant object. And if they can be used in place of the standard components, that's a bonus as well.

For example, one of the things I'd like to do is an alpha blended mouseover on a TButton. I notice no OwnerDraw event and the code to modify how the button was drawn seems to not be in a place that I can override. Any suggestions, or would I have to strip TButton and all its ancestors out of the VCL code and modify it directly?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

淡淡绿茶香 2024-12-07 02:37:41

您可以选择以下方法之一:

  • 覆盖表单的 ReadState,如 此处
  • 使用interposer类,如下所述此处此处
  • 分配一个新的WindowProc,如所解释的此处

You can choose one of the following methods:

  • Override ReadState of your form, as explained here
  • Use an interposer class, as explained here and here
  • Assign a new WindowProc, as explained here.
烟若柳尘 2024-12-07 02:37:41

您提出了几个与开发自定义 VCL 控件相关的问题。

由于这是一个非常广泛的主题,您可能想浏览或搜索有关它的互联网。

作为一个快速问题,有多种方法可以开发或扩展控件。

有时,可以用不同的方式开发相同的控件,
其他,这取决于您想要开发的控制类型。

您还提到如何制作控件,如何与 Delphi IDE 交互

Delphi 控件与包一起使用,您可以使用没有控件的普通库制作一个包,您可能想在制作控件之前开始这样做。

您可以制作一个控件,它根本不交互,只能通过运行应用程序来工作,然后添加与Delphi IDE的交互

在Delphi中,当您开发一个控件并希望将其放在窗体上时,在设计时,在内部,就像 Delphi 是您的应用程序,并且已经拥有您的控制权。

You are making several questions related to developing custom V.C.L. controls.

Since, its a very extended topic, you may want to browse or search the internet about it.

As a fast question, there are several ways to develop or extend a control.

Sometimes, the same control can be developed in different ways,
other, it depends the kind of control, that you want to develop.

You also mention how to make a control, interact with the Delphi I.D.E.

Delphi controls work with packages, you can make a package with plain libraries without controls, you may want to start doing that, before making a control.

You can make a control, that doesn't interact at all, and only works by running the application, and later add interaction with the Delphi I.D.E.

In Delphi, when you develop a control and want to put it on form, while designing, internally, its like Delphi was your application, and already have your control.

桃扇骨 2024-12-07 02:37:41

如果您想更改应用程序中所有 TButton 的外观,则无需修改 VCL 即可完成。当存在几百个按钮组件时,我认为没有必要自己修改 VCL 控件甚至子类化。例如,对于 alpha 混合的鼠标悬停,只需查看 TMS 控件即可。

然而,对于自己动手的技术;方法一(建议简单)是简单地从应用程序中取出所有 TButton,并用其他东西替换它。通过 gExperts 可以轻松完成 VCL 组件替换(全局)。要了解如何将标准控件外观(按钮的外观)与 Delphi 代码中绘制的一些重叠元素相结合,请参阅 TBitBtn 作为示例。我建议您检查 TBitBtn 源代码并从它开始,而不是继承 TButton 或 TCustomButton。

方法二(不推荐这么简单)是开始使用皮肤系统,它可以绘制与标准控件完全不同的外观。

If you want to change the appearance of all TButtons in your application, you can do it without modifying the VCL at all. I see no necessity to modify or even subclass a VCL control yourself, when a few hundred button components exist out there. For example, for alpha-blended mouseovers, just check out the TMS controls.

However, for do-it-yourself techniques; Method one (recommended as simple) is to simply take all the TButtons out of your application and replace it with something else. VCL component replacement (globally) is easily done via gExperts. To see how to combine a standard control appearance (how a button looks) with some overlaid elements drawn in Delphi code, see TBitBtn as a sample. Rather than subclassing TButton or TCustomButton, I recommend you examine TBitBtn sources, and start from it.

Method two (not recommended as simple) is to start using a skinning system which can draw a completely different appearance over standard controls.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文