[DUG] Creating an object at run time.
Kyley Harris
Kyley at harrissoftware.com
Mon Jul 16 17:28:58 NZST 2012
normally it implies that registerclass has not been used on that class in
the application.
to double check, use tstream.writecomponent and see if it works without
error. then do a
readcomponent to see if it can look up the class info properly
On Mon, Jul 16, 2012 at 12:41 PM, David O'Brien <Dave at iccs.co.nz> wrote:
> Very frustrating, I'm getting "Class TButton not Found" with the below
> code. Everything in the uses clause is correct: I have a Tbutton on the
> form at design time. The form is in a .bpl if that will make a
> difference?
>
> // Simplified...
> Uses ..., StdCtrls, ...
> Var
> o: TComponent ;
> ot: String ;
> begin
> ot := 'TButton' ;
> o := TComponentClass(FindClass(ot)).Create(nil); <--- Class
> TButton Not Found
> end ;
>
> -----Original Message-----
> From: delphi-bounces at listserver.123.net.nz
> [mailto:delphi-bounces at listserver.123.net.nz] On Behalf Of Todd Martin
> Sent: Friday, 13 July 2012 4:27 p.m.
> To: NZ Borland Developers Group - Delphi List
> Subject: Re: [DUG] Creating an object at run time.
>
> b := TComponentClass(FindClass('TButton')).Create(nil);
> propinfo := GetPropInfo(b.classinfo,'left'); SetOrdProp(b,propinfo,100);
>
> > I want to create an object at runtime given a string with the object
> type. Is this possible or do I need to do a whole pile of if then
> else's? There is a limited number of different objects that need to be
> created. I then want to access the created objects properties by name
> and assign methods.
> >
> > This is not for oleobjects, but VCL controls.
> >
> > i.e.
> > b := CreateObject('TButton') ;
> > b.GetField('left') := 100 ;
> > ...
> >
> > Help on any of these would be appreciated.
> >
> > Cheers,
> > Dave.
> >
> >
> > _______________________________________________
> > NZ Borland Developers Group - Delphi mailing list
> > Post: delphi at listserver.123.net.nz
> > Admin: http://delphi.org.nz/mailman/listinfo/delphi
> > Unsubscribe: send an email to delphi-request at listserver.123.net.nz
> > with Subject: unsubscribe
>
>
> _______________________________________________
> NZ Borland Developers Group - Delphi mailing list
> Post: delphi at listserver.123.net.nz
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to delphi-request at listserver.123.net.nz with
> Subject: unsubscribe
>
> _______________________________________________
> NZ Borland Developers Group - Delphi mailing list
> Post: delphi at listserver.123.net.nz
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to delphi-request at listserver.123.net.nz with
> Subject: unsubscribe
>
--
Kyley Harris
Harris Software
+64-21-671-821
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20120716/b57fc80e/attachment.html
More information about the Delphi
mailing list