BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TCollectionItem Inheritance

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing
View previous topic :: View next topic  
Author Message
Marco Cotroneo
Guest





PostPosted: Fri Oct 10, 2003 2:38 pm    Post subject: TCollectionItem Inheritance Reply with 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





PostPosted: Fri Oct 10, 2003 2:52 pm    Post subject: Re: TCollectionItem Inheritance Reply with quote



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





PostPosted: Fri Oct 10, 2003 3:02 pm    Post subject: Re: TCollectionItem Inheritance Reply with quote



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





PostPosted: Sat Oct 11, 2003 12:21 am    Post subject: Re: TCollectionItem Inheritance Reply with quote

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





PostPosted: Mon Oct 13, 2003 9:32 am    Post subject: Re: TCollectionItem Inheritance Reply with quote


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





PostPosted: Mon Oct 13, 2003 3:33 pm    Post subject: Re: TCollectionItem Inheritance Reply with quote

Yes You were right I did not assing the button Smile 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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.