如何在一个单元中定义的组件添加到Delphi面板中? [英] How to add to the Delphi palette a component defined in a unit?

查看:95
本文介绍了如何在一个单元中定义的组件添加到Delphi面板中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个pas单元来定义组件。

I have a pas unit defining a component.

如何将其添加到调色板中?我知道的唯一方法是将其包含在软件包中,这是直接的方法吗?

How can I add it to the palette? the only way I know is to include it in a package, is tehre a direct way to do it?

推荐答案

,有一个单元具有名为 Register 的过程-大写字母很重要。在该过程中,调用 RegisterComponents a。

In a package, have a unit that has a procedure named Register — the capitalization is important. In that procedure, call RegisterComponents on the component you'd like to appear on the Tool Palette.

您必须使用软件包。这是IDE加载可执行代码的唯一方法。它不能直接执行DCU文件。如果尚未使用其他软件包,则可以将组件添加到DclUsr软件包中。

You must use packages. That's the only way the IDE will load the executable code; it cannot execute DCU files directly. If you don't already have some other package to use, you can add your component to the DclUsr package.

对于任何明显复杂的组件库,通常都会有至少两个包。将有一个包含所有组件的运行时包,然后将有一个包含 Register 过程的设计时包。

With component libraries of any appreciable complexity, there will usually be at least two packages. There will be a run-time package that contains all the components, and then there will be a design-time package that contains the Register procedures.

这篇关于如何在一个单元中定义的组件添加到Delphi面板中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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