views:

58

answers:

1

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 component.

+2  A: 

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

Neftalí
TFAbout can't be the *unit*. It needs to be a *type*.
Rob Kennedy
It's a mistake. TFAbout it's a type defined in a new Unit.
Neftalí
i am using D2009 and why is it the DesignIntf.dcu, DesignEditors.dcu are'nt found? do i have to install it?
XBasic3000
Hello XBasic3000. In the package(DPK or dproj) at section requires you must add tge DESIGNIDE package.
Neftalí