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 

Naming components inside a component in the IDE

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





PostPosted: Thu Aug 14, 2003 2:58 pm    Post subject: Naming components inside a component in the IDE Reply with quote



I have created my own component. It happens to contain other components. I
create these other components on the fly. I would like to name the
components in a unique way, as the IDE does. How do I get a unique name for
my contained components?

I made this component years ago and avoided the issue by just not naming
them. When I did name them, I was getting a name conflict when I put
another instance of my object on the form since the SAME names were being
used for the contained components for each instance. Hope that made sense.

In any event, I have a need for naming them now. And it looked goofy in the
property inspector when there was no name on the objects. It would show the
class of the object when there was no name either.

So anyway, I need to be able to rename my contained objects in a unique
fashion at design time as the IDE does when it places new objects on the
form.


Back to top
Mark L. Tiede
Guest





PostPosted: Thu Aug 14, 2003 3:10 pm    Post subject: Re: Naming components inside a component in the IDE Reply with quote



Oops. I meant to say

Quote:
It would NOT show the
class of the object when there was no name either.

"Mark L. Tiede" <mtiede (AT) mjwcorp (DOT) com> wrote

Quote:
I have created my own component. It happens to contain other components.
I
create these other components on the fly. I would like to name the
components in a unique way, as the IDE does. How do I get a unique name
for
my contained components?

I made this component years ago and avoided the issue by just not naming
them. When I did name them, I was getting a name conflict when I put
another instance of my object on the form since the SAME names were being
used for the contained components for each instance. Hope that made
sense.

In any event, I have a need for naming them now. And it looked goofy in
the
property inspector when there was no name on the objects. It would show
the
class of the object when there was no name either.

So anyway, I need to be able to rename my contained objects in a unique
fashion at design time as the IDE does when it places new objects on the
form.





Back to top
Robert Cerny
Guest





PostPosted: Thu Aug 14, 2003 5:16 pm    Post subject: Re: Naming components inside a component in the IDE Reply with quote



Your best bet is to convert it to Frame.
1. you solve this issue.
2. you create/modify this compound component in designer, instead in code

Otherwise use a name generator function:
procedure AssignComponentName(Item:TComponent);
var A : integer;
C : TComponent;
Default:string
begin
Default := Item.ClassName;
delete(Default,1,1);
for A := 1 to MaxInt do if
Item.Owner.FindComponent(Default+IntToStr(A))=nil then begin
Item.Name := Default+IntToStr(A);
Exit;
end;
end;

--
Robert Cerny
http://codecentral.borland.com/codecentral/ccWeb.exe/author?authorid=18355

"Mark L. Tiede" <mtiede (AT) mjwcorp (DOT) com> wrote

Quote:
I have created my own component. It happens to contain other components.
I
create these other components on the fly. I would like to name the
components in a unique way, as the IDE does. How do I get a unique name
for
my contained components?

I made this component years ago and avoided the issue by just not naming
them. When I did name them, I was getting a name conflict when I put
another instance of my object on the form since the SAME names were being
used for the contained components for each instance. Hope that made
sense.

In any event, I have a need for naming them now. And it looked goofy in
the
property inspector when there was no name on the objects. It would show
the
class of the object when there was no name either.

So anyway, I need to be able to rename my contained objects in a unique
fashion at design time as the IDE does when it places new objects on the
form.





Back to top
Mark L. Tiede
Guest





PostPosted: Fri Aug 15, 2003 1:10 pm    Post subject: Re: Naming components inside a component in the IDE Reply with quote

Robert,

I don't think I want to make a frame since there may be other consequences
of doing that. I am not aware of any COMPONENTS that are frame descendents,
so I shouldn't have to do that.

As for the second option, the code, this code would only search the OWNER
for similarly named components which would not be guaranteed to work if 2
instances of my object were created with differing owners. Although, maybe
that would be sufficient since for the IDE, the owner is always the form and
when an object is created dynamically at run-time, it doesn't complain about
more than one object with the same name.

I guess I am still searching for an "official" way to go about this. And
since we don't have the IDE source code, we don't know how they determine
unique names when new objects are created.


"Robert Cerny" <robert.qwe.cerny (AT) neosys (DOT) xrs.qwe.si> wrote

Quote:
Your best bet is to convert it to Frame.
1. you solve this issue.
2. you create/modify this compound component in designer, instead in code

Otherwise use a name generator function:
procedure AssignComponentName(Item:TComponent);
var A : integer;
C : TComponent;
Default:string
begin
Default := Item.ClassName;
delete(Default,1,1);
for A := 1 to MaxInt do if
Item.Owner.FindComponent(Default+IntToStr(A))=nil then begin
Item.Name := Default+IntToStr(A);
Exit;
end;
end;

--
Robert Cerny
http://codecentral.borland.com/codecentral/ccWeb.exe/author?authorid=18355

"Mark L. Tiede" <mtiede (AT) mjwcorp (DOT) com> wrote in message
news:3f3ba37a$1 (AT) newsgroups (DOT) borland.com...
I have created my own component. It happens to contain other
components.
I
create these other components on the fly. I would like to name the
components in a unique way, as the IDE does. How do I get a unique name
for
my contained components?

I made this component years ago and avoided the issue by just not naming
them. When I did name them, I was getting a name conflict when I put
another instance of my object on the form since the SAME names were
being
used for the contained components for each instance. Hope that made
sense.

In any event, I have a need for naming them now. And it looked goofy in
the
property inspector when there was no name on the objects. It would show
the
class of the object when there was no name either.

So anyway, I need to be able to rename my contained objects in a unique
fashion at design time as the IDE does when it places new objects on the
form.







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.