Mattias Gaertner wrote 36 lines
On Mon, 24 May 2010 07:01:21 -0300
Luiz Americo Pereira Camara wrote:
> Mattias Gaertner escreveu:
>
>> On Sun, 23 May 2010 23:37:29 -0300
>> Luiz Americo Pereira Camara wrote:
>>
>>
>>
>>> Mattias Gaertner escreveu:
>>> [...]
>>> Here's the actual code (calls a generic TForm descendant):
>>>
>>> The article:
http://lazarusroad.blogspot.com/
>>>
>>>
>> The article does not explain why the properties must be set before
>> calling Loaded.
>>
>>
>>
> If
> procedure TMyForm.Loaded;
> begin
> inherited;
> if MyBool then
> DoAction;
> end;
>
Is this correct:
One of your forms has a design bug, which you can not fix (for
whatever reason), so you need a workaround.
It's not intended at a specific case. I just created a way to call generic TForm descendants with generic properties, basically to avoid boilerplate code. It's is already working fine, i'm just trying to avoid an extra notification (the CM_INIT message). I can also use OnShow or CreateWnd. An example:
TEditMyObjectForm = class(TForm)
[..] //Controls created at design time (stored in the lfm)
published
//customized property
property MyObject: TMyObject;
end;
To show that form setting the property MyObject i would do:
Form := TEditMyObjectForm.Create(nil);
try
Form.MyObject := ObjectX;
Result := Form.ShowModal = mrOk;
finally
Form.Destroy;
end;
With my function i do:
Result := ShowForm(TEditMyObjectForm, nil, ['MyObject', ObjectX]) = mrOk;
Show quoted text 5 lines
I see several solutions:
- Patch and compile your own special version of TReader or LCL.
- modify the lfm at runtime
- modify the VMT at runtime and override Loaded
Wow. Not necessary too much. I can live with a message handler ;-)
Luiz