Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2016-07

How to create a TPicture type property?

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Gabor Boros

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

Reply by email

Michael W. Vogel
to Gabor Boros

Gabor Boros wrote

Show quoted text 25 lines
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 .

Reply by email