Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Component <name> already exists.

975 views
Skip to first unread message

Stephan St-Denis

unread,
Sep 30, 2003, 1:44:34 PM9/30/03
to
Hi,

- Delphi Pro 7

Sometimes, I receive this error message from my program : A component named
<component name here> already exists.

When this error happens, I can't close my program by clicking the close box.

What can cause this problem ?

Any help or advice would be greatly appreciated.

Stephan


Fauschti

unread,
Sep 30, 2003, 1:51:48 PM9/30/03
to
Hi Stephan,

> What can cause this problem ?

Sounds like you are creating controls by code in your application.
If you do so, make sure, you name them unique, otherwise you get those error
messages.
if two components / controls would have the same name in a program, how
could you access them by name, or how should the program know, which one you
mena if you try to access one of them ?

regards,
Michael


Stephan St-Denis

unread,
Oct 8, 2003, 10:55:14 AM10/8/03
to
Dear Michael,

Thanks for your answer. Yes, I'm creating a Form (dialog), named
TcfgPreferences. When the users is finnished with the form, I do
Form.Release;

Sometimes, when the user reopens TcfgPreferences, he gets the message.

Am I doing something wrong ?

Thanks,

Stephan

"Fauschti" <nos...@web.de> a écrit dans le message de news:
3f79...@newsgroups.borland.com...

Fauschti

unread,
Oct 8, 2003, 1:21:09 PM10/8/03
to
Hi Stephan,

As i wrote before: make sure, there are no components that have the same
name.

In your case, i guess something like this might be a good solution:

// make this a procedure in your form that shows the dialog,
// or just edit the code so that it fits your needs
procedure TForm1.ShowMyForm;
begin
if not Assigned(myDialog) then // only create the form, if it does not yet
exist
Application.CreateForm(TcfgPreferences, myDialog);
with myDialog do
try
Update; // optional, i usually call it
ShowModal; // makes the dialog a modal form
finally
Free; // Frees the dialog after the user has done the input ...
// Alternative: FreeAndNil(myDialog);
// BUT: do not call both, free and freeandnil on the same object !
end;
end;

If you do not autocreate your form in the .DPR the first line might not be
necessary.

My Questions:
WHEN and WHERE do you call "Form.Release" in your project?
inside of the dialog that is to be released? or from another unit ?
.release should be called from inside a form, so that it has time to release
all owned controls / components. there have been several discussions about
.free and .release here, just search the news.

If my example does not work for you or if you have any further questions,
post a follow up here.

--
Mit freundlichen Grüßen aus dem regnerischen Deutschland,
Michael Faust
Alpha Interactive - [ www.alpha-interactive.de ]

"Stephan St-Denis" <step...@progicielsconcept.com> schrieb im Newsbeitrag
news:3f84253c$3...@newsgroups.borland.com...

0 new messages