normally it implies that registerclass has not been used on that class in the application.<br>to double check, use tstream.writecomponent and see if it works without error. then do a <br>readcomponent to see if it can look up the class info properly<br>
<br><div class="gmail_quote">On Mon, Jul 16, 2012 at 12:41 PM, David O&#39;Brien <span dir="ltr">&lt;<a href="mailto:Dave@iccs.co.nz" target="_blank">Dave@iccs.co.nz</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Very frustrating, I&#39;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>
  o: TComponent ;<br>
  ot: String ;<br>
begin<br>
      ot := &#39;TButton&#39; ;<br>
      o := TComponentClass(FindClass(ot)).Create(nil); &lt;--- Class<br>
TButton Not Found<br>
end ;<br>
<div class="im HOEnZb"><br>
-----Original Message-----<br>
From: <a href="mailto:delphi-bounces@listserver.123.net.nz">delphi-bounces@listserver.123.net.nz</a><br>
[mailto:<a href="mailto:delphi-bounces@listserver.123.net.nz">delphi-bounces@listserver.123.net.nz</a>] On Behalf Of Todd Martin<br>
Sent: Friday, 13 July 2012 4:27 p.m.<br>
</div><div class="im HOEnZb">To: NZ Borland Developers Group - Delphi List<br>
Subject: Re: [DUG] Creating an object at run time.<br>
<br>
</div><div class="HOEnZb"><div class="h5">b := TComponentClass(FindClass(&#39;TButton&#39;)).Create(nil);<br>
propinfo := GetPropInfo(b.classinfo,&#39;left&#39;); 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&#39;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(&#39;TButton&#39;) ;<br>
&gt; b.GetField(&#39;left&#39;) := 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">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">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">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<br>
Subject: unsubscribe<br>
<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<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Kyley Harris<br>Harris Software<br>+64-21-671-821<br>