At design time, I can create my component on a form, but when I try to remove it, the access violation exception raises.
What I did wrong?
unit SCLabeledEdit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls,
ExtCtrls;
type
{ TSCLabeledEdit }
TSCLabeledEdit = class(TPanel)
private
protected
leTopLabel, leBottomLabel: TLabel;
published
property TopLabel: TLabel read leTopLabel;
property BottomLabel: TLabel read leBottomLabel;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('SemperCOM',[TSCLabeledEdit]);
end;
{ TSCLabeledEdit }
constructor TSCLabeledEdit.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
Caption:=''; Text:='';
{with GetControlClassDefaultSize do
SetInitialBounds(0, 0, CX, CY);}
leTopLabel:=TLabel.Create(TheOwner);
with leTopLabel do begin
Parent:=Self;
SetSubComponent(True);
end;
leBottomLabel:=TLabel.Create(TheOwner);
with leBottomLabel do begin
Parent:=Self;
SetSubComponent(True);
end;
end;
destructor TSCLabeledEdit.Destroy;
begin
leTopLabel.Free;
leBottomLabel.Free;
inherited Destroy;
end;
end.