我需要帮助制作一个控件属性,当您单击它时,弹出一个自定义对话框,就像设置一样。就像TPicture一样。
有什么想法或建议吗?
如果你的类被其他组件作为属性使用,并且你想要使用对象检查器来调用你的对话框,那么你需要实现并注册一个自定义属性编辑器,例如:
interface
uses
DesignIntf, DesignEditors;
type
TMyClassProperty = class(TPropertyEditor)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
end;
procedure Register;
implementation
uses
MyClassUnit;
procedure TMyClassProperty.Edit;
begin
with TMyDialog.Create(nil) do
try
ShowModal;
finally
Free;
end;
end;
function TMyClassProperty.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes + [paDialog];
end;
procedure Register;
begin
RegisterPropertyEditor(TypeInfo(TMyClass), nil, '', TMyClassProperty);
end;