我想在我的自定义组件上添加关于框/对话框。如何使小按钮 [...] 出现在对象检查器上?就像在 Timage 组件上分配图片一样。
问问题
376 次
1 回答
2
您必须定义一个与此类似的属性:
//: Información acerca del paquete de componentes
property AboutMe:TFAbout read FAboutG stored false;
TFAbout是一个类,它定义了当用户单击“Object Inspector”中的属性时要查看的表单(关于表单)。
此外,如果您想看到带有三点 |...| 的按钮,您必须注册一个“属性编辑器”。在 OI 中。
这是一个样本单元:
unit UTAboutProp;
interface
uses
DesignIntf, DesignEditors;
type
TAboutGProp = class(TPropertyEditor)
public
procedure Edit(); override;
function GetValue(): string; override;
function GetAttributes(): TPropertyAttributes; override;
end;
implementation
uses
SysUtils, FormAbout, UConstantes;
procedure TAboutGProp.Edit();
begin
with TFAbout.Create(nil) do
try
ShowModal();
finally
Free();
end;
end;
function TAboutGProp.GetValue(): string;
begin
result := Format(GLIBSI_LBL,[GLIBSI_VERSION]);
result := '1.0';
end;
function TAboutGProp.GetAttributes(): TPropertyAttributes;
begin
result := [paDialog,paReadOnly];
end;
end.
只需“注册”此“属性编辑器”即可使用您的 About 属性;这对于将您的属性与您的编辑器“链接”很重要。
如果您有注册组件的代码,请添加注册属性的代码:
RegisterPropertyEditor(TypeInfo(TFAbout),nil,'',TAboutGProp);
问候
于 2010-07-19T09:13:35.713 回答