一番搜索之后,它看起来像我不得不分配RegisterComponentsProc和RegisterPropertyEditorProc,这是我做的事.
但是,我认为我可以调用我的设计时间寄存器功能,即<myComponentUnit>.Register();.
当我这样做时,我得到堆栈溢出,因为,好吧......
procedure myComponentUnit.Regiter;
begin
RegisterPropertyEditor(TypeInfo(Integer),
TMyComponent, 'myProperty', TMyProperty);
Run Code Online (Sandbox Code Playgroud)
结束;
procedure RegisterPropertyEditor(PropertyType: PTypeInfo;
ComponentClass: TClass; const PropertyName: string;
EditorClass: TPropertyEditorClass);
begin
if Assigned(RegisterPropertyEditorProc) then
RegisterPropertyEditorProc(PropertyType, ComponentClass, PropertyName,
EditorClass);
end;
Run Code Online (Sandbox Code Playgroud)
所以,我打电话给.Register();
调用RegisterPropertyEditorProc()
调用RegisterPropertyEditorProc()
调用RegisterPropertyEditor()<=== aaargh !!
那么,我应该在RegisterPropertyEditorProc的主体中拥有什么?
进一步搜索后,看起来我想DesignEditors.RegisterPropertyEditor()直接调用,但它不在界面部分......
Delphi不包含DesignEditors单元的源代码。它的实现仅在DesignIDE软件包中提供。该软件包可以访问IDE内部,例如注册的属性编辑器列表。IDE将值分配给RegisterComponentsProc和RegisterPropertyEditorProc回调函数。如您所见,RegisterPropertyEditor调用RegisterPropertyEditorProc。IDE提供了自己的功能来处理该事件。
如果要在运行时注册属性编辑器,则程序将扮演IDE的角色。您需要为这些回调函数提供实现,以便在您自己的属性编辑框架中注册属性编辑器类。您可能只需将所有内容保存在简单列表中即可。然后,当您想知道针对某种类型的属性显示哪种编辑器时,请查阅列表以查找最佳匹配。
您是正确的,应该致电您所在单位的注册程序。但这是您启动注册过程的方式,而不是实现它的方式。那部分取决于你;Delphi不为您提供任何此类服务。