开发者

how to add TAboutBox in TCustomControls?

开发者 https://www.devze.com 2023-01-07 16:37 出处:网络
I want to add aboutbox/dialogbox on my Custom component. how to make the small button[...] appear on the object inspector? just like the assigning a picure on the Timage compone开发者_运维知识库nt. Yo

I want to add aboutbox/dialogbox on my Custom component. how to make the small button[...] appear on the object inspector? just like the assigning a picure on the Timage compone开发者_运维知识库nt.


You must define a property similar to this:

//: Información acerca del paquete de componentes
property AboutMe:TFAbout read FAboutG stored false;

TFAbout is a class, that define the form that you want to see (About form), when the user click on the property in "Object Inspector".

Additionally, you must register a "Property Editor", if you want see a buuton with the three point |...| in OI.

This is a sample unit:

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.

Only rest to "register" this "property Editor" for work with your About property; This is important for "link" your property with your editor.

Where you have the code for register the component, add the code for register the property:

  RegisterPropertyEditor(TypeInfo(TFAbout),nil,'',TAboutGProp);

Regards

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号