[Lazarus] Should using frames result in duplicate name errors?

Marc Weustink marc.weustink at cuperus.nl
Thu Nov 18 10:41:22 CET 2010


Steve Smith wrote:
> 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.

BTW, if you onlt create components in code, you don't have to give it a 
name.

Marc




More information about the Lazarus mailing list