[Lazarus] Hook TComponent streaming system

Luiz Americo Pereira Camara luizmed at oi.com.br
Sat May 22 23:33:47 CEST 2010


Michael Van Canneyt escreveu:
>
>
> On Sat, 22 May 2010, Luiz Americo Pereira Camara wrote:
>
>> I'd like to set some properties of a TComponent(TForm) through RTTI 
>> before TComponent.Loaded is called.
>>
>> After a call to TMyForm.Create, the component is initiated through 
>> the streaming system that calls Loaded.
>>
>> Is there a way to hook this streaming system so i can change the 
>> properties before the call to Loaded?
>
> You can use defineproperties for that. You can simply override it in  
> your
> form and set whatever properties you want. An alternative is overriding
> 'Loading', which is called at the start.

Thanks. But i think that won't help me. I'm creating a instance of a 
generic TForm (see code below) and than setting the properties after the 
call to constructor.

I would need that the properties be set after loading the stored 
properties and before FormClass.Loaded is called but it's to late.

The problem is that Loaded is called inside the constructor call chain. 
I could create the instance through NewInstance but AFAIK that is too 
early (before creating the stored/published properties).

var
  Form: TForm;
begin
  //FormClass: TFormClass
  Form := FormClass.Create(Owner);
  SetObjectProperties(Form, FormProperties);
  [..]
end;


Luiz




More information about the Lazarus mailing list