[Lazarus] How to create a TPicture type property?

Michael W. Vogel m-w-vogel at gmx.de
Sun Jul 17 22:40:16 CEST 2016


Gabor Boros wrote
> Hi All,
> 
> I have a component like this:
> 
> TMyComponent=class(TPersistent)
> private
>    FPicture:TPicture;
> public
>    constructor Create;
> published
>    property Picture:TPicture read FPicture write FPicture;
> end;
> 
> constructor TMyComponent.Create;
> begin
>    inherited;
> 
>    FPicture:=TPicture.Create;
> end;
> 
> When click on the Picture property in OI the "Load Image Dialog" showed 
> then click on Load button and got SIGSEGV. Where is the source of the 
> problem?
> 
> Gabor

AFAIK as I know, you have to derive minimal from TComponent. Just tested
(and it works for me):

  TMyComponent = class(TComponent)
  private
    FPicture: TPicture;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  published
    property Picture: TPicture read FPicture write FPicture;
  end;

constructor TMyComponent.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FPicture := TPicture.Create;
end;

destructor TMyComponent.Destroy;
begin
  FPicture.Free;
  inherited Destroy;
end; 

I've added the simple TMyComponent package. MyComponents.zip
<http://free-pascal-lazarus.989080.n3.nabble.com/file/n4049040/MyComponents.zip>  

Kind regards

Michael



--
View this message in context: http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-How-to-create-a-TPicture-type-property-tp4049018p4049040.html
Sent from the Free Pascal - Lazarus mailing list archive at Nabble.com.


More information about the Lazarus mailing list