[Lazarus] constructor Create How is it work?
FreeMan
freeman35 at delphiturkiye.com
Tue Mar 4 16:19:23 CET 2014
ExLookUp1:=TExLookUp.Create(Form1); This is for manual creating, I'm
talk about, I'm designing in IDE, 1-2 TExLookUp on form, and run my
application, TExLookUp is class(TCustomEditButton) so Edit and button is
shown on where I put on form, in designtime IDE.
constructor TExLookUp.Create(AOwner: TComponent);
begin inherited Create(AOwner);
Self.OnChange := @EditChange;
FGrid := TRxDBGrid.Create(Self);
FGrid.Parent := Self.Parent;
FGrid.Left := Self.Left;
FGrid.Top := Self.Heigh + 10;
FGrid.Width := 150;
FGrid.visible := False;
...
set FGrid.visible := False; FGrid not visible, same where in component,
example in TExLookUp.OnClick event writen this code
"FGrid.visible := True;" and while application running, user click button,
FGrid not visible, Because in create "FGrid.Parent := Self.Parent;"
and FGrid=nil, has not parent and FGrid not showing.
FGrid.Left=0 and
FGrid.Top=10
similar problem, when I porting component, Main component has maybe more
10 class create in Main created procedure.Huge class not created and
other class has need some property from huge class, but huge class not
created and accesses volation error generated, I fixed that, I added "if
assigned()then" this is runaway from problem just, not mean fixed
another problem same on porting:
(not clearly analysis) another create problem:
TxItem = class(TCollectionItem)
....
constructor Tx.Create(Collection: TCollection);
begin
inherited Create(Collection);
.....
FName := 'XItem' + IntToStr(Index); --> FName is Item's name,
TCollection.Index is always 0(zero). Collection has to added so it has a
index number from TCollectionItem, but not known.
The order of setting properties is arbitrary. Your component should work
with any order.
Sorry, but I'm scared this answer, because nothing my under control
04-03-2014 12:10 tarihinde, Mattias Gaertner yazdı:
> ExLookUp1:=TExLookUp.Create(Form1);
> with ExLookUp1 do begin
> Name:='ExLookUp1';
> Parent:=Form1;
> Left:=10;
> Top:=15;
> ...
> end;
>
> The order of setting properties is arbitrary. Your component should work
> with any order. Keep in mind that properties might be set multiple
> times.
>
>> constructor TExLookUp.Create(AOwner: TComponent);
>> begin
>> inherited Create(AOwner);
>> Self.OnChange := @EditChange;
>> FGrid := TRxDBGrid.Create(Self);
>> FGrid.Parent := Self.Parent;
>> FGrid.Left := Self.Left;
>> FGrid.Top := Self.BoundsRect.Bottom-4;
>> FGrid.Width := Self.BoundsRect.Right - Self.BoundsRect.Left;
> Mattias
>
More information about the Lazarus
mailing list