Thanks, looks like I will...

 

From: [email protected]
[mailto:[email protected]] On Behalf Of Kyley Harris
Sent: Monday, 16 July 2012 6:07 p.m.
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Creating an object at run time.

 

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.

Have fun. 




On Mon, Jul 16, 2012 at 5:45 PM, David O'Brien <[email protected]> wrote:

Thanks, Oh well... I understand, but I don't really know what classes
will be used, guess I'll just have to register everything L. I would
have thought the standard VCL controls would have been sorted though...

 

 

From: [email protected]
[mailto:[email protected]] On Behalf Of Kyley Harris
Sent: Monday, 16 July 2012 5:35 p.m.


To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Creating an object at run time.

 

David,

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).

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.

begin
  RegisterClass(TButton);
  with TComponentClass(FindClass('TButton')).Create(self)  as tbutton
do
  begin
     top := 10;
     left := 10;
     caption := 'hello';
     width := 100;
    parent := self;
  end;

On Mon, Jul 16, 2012 at 12:41 PM, David O'Brien <[email protected]> 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: [email protected]
[mailto:[email protected]] 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: [email protected]
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to [email protected]
> with Subject: unsubscribe


_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: [email protected]
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to [email protected] with
Subject: unsubscribe

_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: [email protected]
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to [email protected] with
Subject: unsubscribe




-- 
Kyley Harris
Harris Software
+64-21-671-821


_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: [email protected]
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to [email protected] with
Subject: unsubscribe




-- 
Kyley Harris
Harris Software
+64-21-671-821

_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: [email protected]
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to [email protected] with 
Subject: unsubscribe

Reply via email to