| View previous topic :: View next topic |
| Author |
Message |
Marco Cotroneo Guest
|
Posted: Fri Oct 10, 2003 2:38 pm Post subject: TCollectionItem Inheritance |
|
|
Hello,
I have inherited a new control from TPanel and add it a new Collection
Property to create buttons runtime. When I try to inherit the form where the
new panel is on I get an exception with message "Can't assing a
tCollectionItem to a CollectionItem". I overrided the Assing Method of the
TCollectionItem, but still can't inherit it. I enclose the code can anyone
tell me where I go wrong?
Thanks
marco
if Source is TColButtonItem then
begin
if Assigned(Collection) then Collection.BeginUpdate;
try
Self.FShowHint := TColButtonItem(Source).ShowHint;
Self.FHint := TColButtonItem(Source).Hint;
Self.FCaption := TColButtonItem(Source).Caption;
Self.FModulo := TColButtonItem(Source).Modulo;
(*Assign the Button*)
Self.FBtn := TColButtonItem(Source).btn;
Self.FParent := TColButtonItem(Source).Parent;
Self.FImageIndex := TColButtonItem(Source).ImageIndex;
Self.FWindowTitle := TColButtonItem(Source).WindowTitle;
Self.FKind := TColButtonItem(Source).Kind;
Self.FUcase := TColButtonItem(Source).Ucase;
TColButton(Collection).SetBtnProp;
TColButton(Collection).SetBtnPos;
Collection.EndUpdate;
finally
if Assigned(Collection) then Collection.EndUpdate;
end;
end
else
inherited;
|
|
| Back to top |
|
 |
Marco Cotroneo Guest
|
Posted: Fri Oct 10, 2003 2:52 pm Post subject: Re: TCollectionItem Inheritance |
|
|
I findout where the problem was...
I should set the btn property before the others.
Thank as well
"Marco Cotroneo" <m.cot (AT) titol (DOT) it> ha scritto nel messaggio
news:3f86c521 (AT) newsgroups (DOT) borland.com...
| Quote: | Hello,
I have inherited a new control from TPanel and add it a new Collection
Property to create buttons runtime. When I try to inherit the form where
the
new panel is on I get an exception with message "Can't assing a
tCollectionItem to a CollectionItem". I overrided the Assing Method of
the
TCollectionItem, but still can't inherit it. I enclose the code can
anyone
tell me where I go wrong?
Thanks
marco
if Source is TColButtonItem then
begin
if Assigned(Collection) then Collection.BeginUpdate;
try
Self.FShowHint := TColButtonItem(Source).ShowHint;
Self.FHint := TColButtonItem(Source).Hint;
Self.FCaption := TColButtonItem(Source).Caption;
Self.FModulo := TColButtonItem(Source).Modulo;
(*Assign the Button*)
Self.FBtn := TColButtonItem(Source).btn;
Self.FParent := TColButtonItem(Source).Parent;
Self.FImageIndex := TColButtonItem(Source).ImageIndex;
Self.FWindowTitle := TColButtonItem(Source).WindowTitle;
Self.FKind := TColButtonItem(Source).Kind;
Self.FUcase := TColButtonItem(Source).Ucase;
TColButton(Collection).SetBtnProp;
TColButton(Collection).SetBtnPos;
Collection.EndUpdate;
finally
if Assigned(Collection) then Collection.EndUpdate;
end;
end
else
inherited;
|
|
|
| Back to top |
|
 |
Marco Cotroneo Guest
|
Posted: Fri Oct 10, 2003 3:02 pm Post subject: Re: TCollectionItem Inheritance |
|
|
Unfortunately the problem still stand , I think the proble is the button I
create. Each time I add a new CollectionItem (tCollectionItem.Create) I
create a button which is hold by the property btn. Should I meange it in
such a particolary way?
thanks
Marco
| Quote: | if Source is TColButtonItem then
begin
if Assigned(Collection) then Collection.BeginUpdate;
try
Self.FShowHint := TColButtonItem(Source).ShowHint;
Self.FHint := TColButtonItem(Source).Hint;
Self.FCaption := TColButtonItem(Source).Caption;
Self.FModulo := TColButtonItem(Source).Modulo;
(*Assign the Button*)
Self.FBtn := TColButtonItem(Source).btn;
Self.FParent := TColButtonItem(Source).Parent;
Self.FImageIndex := TColButtonItem(Source).ImageIndex;
Self.FWindowTitle := TColButtonItem(Source).WindowTitle;
Self.FKind := TColButtonItem(Source).Kind;
Self.FUcase := TColButtonItem(Source).Ucase;
TColButton(Collection).SetBtnProp;
TColButton(Collection).SetBtnPos;
Collection.EndUpdate;
finally
if Assigned(Collection) then Collection.EndUpdate;
end;
end
else
inherited;
|
|
|
| Back to top |
|
 |
Yaguar Guest
|
Posted: Sat Oct 11, 2003 12:21 am Post subject: Re: TCollectionItem Inheritance |
|
|
Where exactly is the exception triggered in your posted code?
What type is "self"?
In which method/function/procedure/constructor is you source located?
What is Self.FParent := TColButtonItem(Source).Parent; for?
Bye - Yaguar
|
|
| Back to top |
|
 |
R. Vermeij Guest
|
Posted: Mon Oct 13, 2003 9:32 am Post subject: Re: TCollectionItem Inheritance |
|
|
| Quote: | (*Assign the Button*)
Self.FBtn := TColButtonItem(Source).btn;
|
You assign the buffer reference (in fact, just a pointer).
I might be wrong, but don't you intend to copy the button?
FBtn := TButton.Create(_SomeOwner_);
FBtn.Parent := _SomeParentMightBeSameAs_SomeOwner_;
FBtn.Assign(TColButtonItem(Source).btn);
Code is not tested!
Ruud
(Remove SPAM)
|
|
| Back to top |
|
 |
Marco Cotroneo Guest
|
Posted: Mon Oct 13, 2003 3:33 pm Post subject: Re: TCollectionItem Inheritance |
|
|
Yes You were right I did not assing the button thanks
"R. Vermeij" <rSv (AT) veroPmAMatic (DOT) nl> ha scritto nel messaggio
news:3f8a7126$1 (AT) newsgroups (DOT) borland.com...
| Quote: |
(*Assign the Button*)
Self.FBtn := TColButtonItem(Source).btn;
You assign the buffer reference (in fact, just a pointer).
I might be wrong, but don't you intend to copy the button?
FBtn := TButton.Create(_SomeOwner_);
FBtn.Parent := _SomeParentMightBeSameAs_SomeOwner_;
FBtn.Assign(TColButtonItem(Source).btn);
Code is not tested!
Ruud
(Remove SPAM)
|
|
|
| Back to top |
|
 |
|