<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";
        mso-fareast-language:EN-NZ;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-NZ link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thanks, looks like I will...<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> delphi-bounces@listserver.123.net.nz [mailto:delphi-bounces@listserver.123.net.nz] <b>On Behalf Of </b>Kyley Harris<br><b>Sent:</b> Monday, 16 July 2012 6:07 p.m.<br><b>To:</b> NZ Borland Developers Group - Delphi List<br><b>Subject:</b> Re: [DUG] Creating an object at run time.<o:p></o:p></span></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>They dont need to. DFM use read component and you pass an existing instance.. ie TFORM as the top layer. it then uses the runtime information of the instance to stream the data. ie.. a button on the form as a property has runtime information, but its not registered with GetClass.. the only difference is that you need global lookup. the class info is in memory, just not in the lookup list.<br><br>Have fun. <br><br><br><o:p></o:p></p><div><p class=MsoNormal>On Mon, Jul 16, 2012 at 5:45 PM, David O'Brien &lt;<a href="mailto:Dave@iccs.co.nz" target="_blank">Dave@iccs.co.nz</a>&gt; wrote:<o:p></o:p></p><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thanks, Oh well... I understand, but I don&#8217;t really know what classes will be used, guess I&#8217;ll just have to register everything </span><span style='font-size:11.0pt;font-family:Wingdings;color:#1F497D'>L</span><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>. I would have thought the standard VCL controls would have been sorted though...</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> <a href="mailto:delphi-bounces@listserver.123.net.nz" target="_blank">delphi-bounces@listserver.123.net.nz</a> [mailto:<a href="mailto:delphi-bounces@listserver.123.net.nz" target="_blank">delphi-bounces@listserver.123.net.nz</a>] <b>On Behalf Of </b>Kyley Harris<br><b>Sent:</b> Monday, 16 July 2012 5:35 p.m.</span><o:p></o:p></p><div><div><p class=MsoNormal><br><b>To:</b> NZ Borland Developers Group - Delphi List<br><b>Subject:</b> Re: [DUG] Creating an object at run time.<o:p></o:p></p></div></div><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;margin-bottom:12.0pt'>David,<br><br>a basic test on a blank form shows that the following code doesn't work unless registerclass is called first (of course you'd only do this 1 time).<br><br>clearly they are not registering these classes by default for streaming. you will probably find that the Delphi IDE registers them all internally for DFM creation, but they haven't done it by default for end runtime code.<br><br>begin<br>&nbsp; RegisterClass(TButton);<br>&nbsp; with TComponentClass(FindClass('TButton')).Create(self)&nbsp; as tbutton&nbsp;&nbsp;&nbsp; do<br>&nbsp; begin<br>&nbsp;&nbsp;&nbsp;&nbsp; top := 10;<br>&nbsp;&nbsp;&nbsp;&nbsp; left := 10;<br>&nbsp;&nbsp;&nbsp;&nbsp; caption := 'hello';<br>&nbsp;&nbsp;&nbsp;&nbsp; width := 100;<br>&nbsp;&nbsp;&nbsp; parent := self;<br>&nbsp; end;<o:p></o:p></p><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>On Mon, Jul 16, 2012 at 12:41 PM, David O'Brien &lt;<a href="mailto:Dave@iccs.co.nz" target="_blank">Dave@iccs.co.nz</a>&gt; wrote:<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Very frustrating, I'm getting &quot;Class TButton not Found&quot; with the below<br>code. Everything in the uses clause is correct: I have a Tbutton on the<br>form at design time. The form is in a .bpl if that will make a<br>difference?<br><br>// Simplified...<br>Uses ..., StdCtrls, ...<br>Var<br>&nbsp; o: TComponent ;<br>&nbsp; ot: String ;<br>begin<br>&nbsp; &nbsp; &nbsp; ot := 'TButton' ;<br>&nbsp; &nbsp; &nbsp; o := TComponentClass(FindClass(ot)).Create(nil); &lt;--- Class<br>TButton Not Found<br>end ;<o:p></o:p></p><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><br>-----Original Message-----<br>From: <a href="mailto:delphi-bounces@listserver.123.net.nz" target="_blank">delphi-bounces@listserver.123.net.nz</a><br>[mailto:<a href="mailto:delphi-bounces@listserver.123.net.nz" target="_blank">delphi-bounces@listserver.123.net.nz</a>] On Behalf Of Todd Martin<br>Sent: Friday, 13 July 2012 4:27 p.m.<o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;margin-bottom:12.0pt'>To: NZ Borland Developers Group - Delphi List<br>Subject: Re: [DUG] Creating an object at run time.<o:p></o:p></p></div><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>b := TComponentClass(FindClass('TButton')).Create(nil);<br>propinfo := GetPropInfo(b.classinfo,'left'); SetOrdProp(b,propinfo,100);<br><br>&gt; I want to create an object at runtime given a string with the object<br>type. Is this possible or do I need to do a whole pile of if then<br>else's? There is a limited number of different objects that need to be<br>created. I then want to access the created objects properties by name<br>and assign methods.<br>&gt;<br>&gt; This is not for oleobjects, but VCL controls.<br>&gt;<br>&gt; i.e.<br>&gt; b := CreateObject('TButton') ;<br>&gt; b.GetField('left') := 100 ;<br>&gt; ...<br>&gt;<br>&gt; Help on any of these would be appreciated.<br>&gt;<br>&gt; Cheers,<br>&gt; Dave.<br>&gt;<br>&gt;<br>&gt; _______________________________________________<br>&gt; NZ Borland Developers Group - Delphi mailing list<br>&gt; Post: <a href="mailto:delphi@listserver.123.net.nz" target="_blank">delphi@listserver.123.net.nz</a><br>&gt; Admin: <a href="http://delphi.org.nz/mailman/listinfo/delphi" target="_blank">http://delphi.org.nz/mailman/listinfo/delphi</a><br>&gt; Unsubscribe: send an email to <a href="mailto:delphi-request@listserver.123.net.nz" target="_blank">delphi-request@listserver.123.net.nz</a><br>&gt; with Subject: unsubscribe<br><br><br>_______________________________________________<br>NZ Borland Developers Group - Delphi mailing list<br>Post: <a href="mailto:delphi@listserver.123.net.nz" target="_blank">delphi@listserver.123.net.nz</a><br>Admin: <a href="http://delphi.org.nz/mailman/listinfo/delphi" target="_blank">http://delphi.org.nz/mailman/listinfo/delphi</a><br>Unsubscribe: send an email to <a href="mailto:delphi-request@listserver.123.net.nz" target="_blank">delphi-request@listserver.123.net.nz</a> with<br>Subject: unsubscribe<br><br>_______________________________________________<br>NZ Borland Developers Group - Delphi mailing list<br>Post: <a href="mailto:delphi@listserver.123.net.nz" target="_blank">delphi@listserver.123.net.nz</a><br>Admin: <a href="http://delphi.org.nz/mailman/listinfo/delphi" target="_blank">http://delphi.org.nz/mailman/listinfo/delphi</a><br>Unsubscribe: send an email to <a href="mailto:delphi-request@listserver.123.net.nz" target="_blank">delphi-request@listserver.123.net.nz</a> with Subject: unsubscribe<o:p></o:p></p></div></div></div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><br><br clear=all><br>-- <br>Kyley Harris<br>Harris Software<br>+64-21-671-821<o:p></o:p></p></div></div></div></div><p class=MsoNormal><br>_______________________________________________<br>NZ Borland Developers Group - Delphi mailing list<br>Post: <a href="mailto:delphi@listserver.123.net.nz">delphi@listserver.123.net.nz</a><br>Admin: <a href="http://delphi.org.nz/mailman/listinfo/delphi" target="_blank">http://delphi.org.nz/mailman/listinfo/delphi</a><br>Unsubscribe: send an email to <a href="mailto:delphi-request@listserver.123.net.nz">delphi-request@listserver.123.net.nz</a> with Subject: unsubscribe<o:p></o:p></p></div><p class=MsoNormal><br><br clear=all><br>-- <br>Kyley Harris<br>Harris Software<br>+64-21-671-821<o:p></o:p></p></div></body></html>