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'Brien <span dir="ltr"><<a href="mailto:Dave@iccs.co.nz" target="_blank">Dave@iccs.co.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Very frustrating, I'm getting "Class TButton not Found" 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 := 'TButton' ;<br>
o := TComponentClass(FindClass(ot)).Create(nil); <--- 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('TButton')).Create(nil);<br>
propinfo := GetPropInfo(b.classinfo,'left'); SetOrdProp(b,propinfo,100);<br>
<br>
> 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>
><br>
> This is not for oleobjects, but VCL controls.<br>
><br>
> i.e.<br>
> b := CreateObject('TButton') ;<br>
> b.GetField('left') := 100 ;<br>
> ...<br>
><br>
> Help on any of these would be appreciated.<br>
><br>
> Cheers,<br>
> Dave.<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><br>
> 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>