<br><br><div class="gmail_quote">On 17 November 2010 19:28, Mattias Gaertner <span dir="ltr"><<a href="mailto:nc-gaertnma@netcologne.de">nc-gaertnma@netcologne.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">On Wed, 17 Nov 2010 17:45:01 +0000<br>
Frank Church <<a href="mailto:vfclists@gmail.com">vfclists@gmail.com</a>> wrote:<br>
<br>
> I am trying to use frames to create the same element repeatedly on a form,<br>
> but when I copy them in the IDE or create them and set their parents at<br>
> runtime, I get duplicate name errors. Isn't Lazarus supposed to give them<br>
> different names.<br>
<br>
</div>No.<br>
The name is needed for reference.<br>
<div class="im"><br>
<br>
> embFrame1 := TEmbBoothFrame.Create(self);<br>
> embFrame1.Parent := Panel10;<br>
> embFrame1.lblDestination.Caption := 'XXXXX';<br>
><br>
> embFrame2 := TEmbBoothFrame.Create(self);<br>
> embFrame2.Parent := Panel11;<br>
> embFrame2.lblDestination.Caption := 'YYYYY';<br>
><br>
> The above code generates the error:<br>
><br>
> Duplicate name: A component named EmbBoothFrame already exists.<br>
<br>
</div>You can set a new name or set it to the empty name:<br>
embFrame1 := TEmbBoothFrame.Create(self);<br>
embFrame1.Name:='';<br>
embFrame1.Parent := Panel11;<br>
embFrame1.lblDestination.Caption := 'YYYYY';<br>
<div class="im"><br>
<br>
> Is it possible to get it to set a new name at creation time? On closer look<br>
> it looks like the use of self means it is being attached to the form, would Application<br>
> work much better<br>
><br>
> ie embFrame1 := TEmbBoothFrame.Create(Application)?<br>
><br>
> I tested with Application and it works<br>
><br>
> On the other hand it appears that when I add the frames from the IDE, the<br>
> duplicate name issue exists.<br>
><br>
> Is it possible to pass the desired name to the Create function in this case?<br>
<br>
</div>There is a complicated way. But I doubt you really need that.<br>
<div class="im"><br>
<br>
> Are frames the right thing for this or is it templates instead? But I can't<br>
> find templates in the IDE menu or the palette (Lazarus 0.9.28.3).<br>
<br>
</div>What is 'this'?<br>
<br></blockquote><div><br>Because it is the same frame being created from the IDE palette, is it possible to have the child elements in the frame, having the same name, so that at runtime if the parent frames have names such as Parent1, Parent2, Parent3 it possible to write such code as Parent1.Label1.Caption, Parent2.Label1.Caption etc , ie can Lazarus allow child elements to have duplicate names at runtime so long as the parents have different names?<br>
<br>I want to attach events to the child elements, but it seems I can only do it runtime with the Application owning the objects, rather than the form, which is why I am asking whether templates are better for this, rather than frames.<br>
<br><br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Mattias<br>
<font color="#888888"><br>
--<br>
_______________________________________________<br>
Lazarus mailing list<br>
<a href="mailto:Lazarus@lists.lazarus.freepascal.org">Lazarus@lists.lazarus.freepascal.org</a><br>
<a href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus" target="_blank">http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Frank Church<br><br>=======================<br><a href="http://devblog.brahmancreations.com">http://devblog.brahmancreations.com</a><br>