[Lazarus] Should using frames result in duplicate name errors?
Steve Smith
stevie at collector.org
Wed Nov 17 22:55:45 CET 2010
On Wed, 17 Nov 2010 17:45:01 +0000 Frank Church <vfclists at gmail.com>
wrote
> I am trying to use frames to create the same element repeatedly on a
form,
> but when I copy them in the IDE or create them and set their parents
at
> runtime, I get duplicate name errors. Isn't Lazarus supposed to give
them
> different names.
How can Lazarus do it? You are entering code directly. If you use the
IDE
to add frames, Lazarus will do it for you. If you wish to do it in
code
CORRECTLY, do the following.
embFrame1 := TEmbBoothFrame.Create(self);
embFrame1.Name := 'embBoothFrame1';
embFrame1.Parent := Panel10;
embFrame1.lblDestination.Caption := 'XXXXX';
embFrame2 := TEmbBoothFrame.Create(self);
embFrame2.Name := 'embBoothFrame2';
embFrame2.Parent := Panel11;
embFrame2.lblDestination.Caption := 'YYYYY';
Alternatively, you can add code in the TEmbBoothFrame constructor
yourself
to build unique names.
There is a routine somewhere to generate a unique name but I can't be
bothered to search for it.
More information about the Lazarus
mailing list