Mattias Gaertner escreveu:
On Mon, 24 May 2010 07:01:21 -0300
Luiz Americo Pereira Camara <[email protected]> wrote:

Mattias Gaertner escreveu:
On Sun, 23 May 2010 23:37:29 -0300
Luiz Americo Pereira Camara <[email protected]> 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;

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

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to