Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我可以让自定义Delphi组件向uses子句添加多个单元吗?_Delphi_Components - Fatal编程技术网

我可以让自定义Delphi组件向uses子句添加多个单元吗?

我可以让自定义Delphi组件向uses子句添加多个单元吗?,delphi,components,Delphi,Components,我正在研究XE2中的一些组件。是否有可能将多个组件的单元添加到它所丢弃的表单的uses子句中 例如: 当我从我构建和安装的包中选择TCustomComponent时,unitcustomcomponent被添加到表单的uses子句中。我还想添加单位GlobalConstants 有人知道是否可以这样做吗?为您的组件创建一个设计时包(如果您还没有)。在该包中,创建一个实现该接口的类(最简单的方法是从该类派生),重写其虚方法以报告要在使用组件的任何表单/Frame/DataModule的uses子句

我正在研究XE2中的一些组件。是否有可能将多个组件的单元添加到它所丢弃的表单的uses子句中

例如: 当我从我构建和安装的包中选择TCustomComponent时,unitcustomcomponent被添加到表单的uses子句中。我还想添加单位GlobalConstants


有人知道是否可以这样做吗?

为您的组件创建一个设计时包(如果您还没有)。在该包中,创建一个实现该接口的类(最简单的方法是从该类派生),重写其虚方法以报告要在使用组件的任何表单/Frame/DataModule的
uses
子句中显示的任何附加单元。然后,让包的
Register()
函数通过调用(除了)来注册该类

对其
TIdTCPServer
TIdCmdTCPClient
TIdUDPServer
组件执行此操作,以确保
IdContext
IdSocketHandle
单元添加到
uses
子句中。查看
IdCoreSelectionEditors.pas
IdRegisterCore.pas
单元,了解Indy是如何实现这一点的

更新:2014年3月,Indy 10中的
IDCoreSelectionEditor.pas
IDProtocolSelectionEditor.pas
单元被删除。所有每个组件SelectionEditor类都被替换为在
IdRegisterCore
单元本身中实现的一个新类。这个新的SelectionEditor类为所有Indy组件注册,它使用所有参数的数据类型的RTTI和任何指定事件处理程序的返回值来查找在设计时放置的任何Indy组件的所有实例,以了解要报告哪些单元以包含在
uses
子句中