Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Delete modal form
Wed, Jun 19 2013 4:08 AMPermanent Link

Christian Kaufmann

Hi,

in Delphi I used a common pattern for dialogs:

class procedure TMyForm.Execute;
var
 f : TForm;
begin
 f := TMyForm.Create(Application);
 try
   f.ShowModal
 finally
   f.Release;
 end;
end;

Since everything is async in EWB, I cannot do that. So my question is,
where do I delete the temporary modal forms?

I tried this:

procedure TMyForm.FMyFormDlgClose(Sender: TObject);
begin
 TForm(Sender).Free;
end;

it seems to work, but is this really a good way to do it?


cu Christian
Thu, Jun 20 2013 4:10 AMPermanent Link

Matthew Jones

I don't know the answer to your question, but I have just been using the default
create all forms at start and leave them around with just hide(close)/show
operating. It might be more sensible to free them.

One thing I do is use the "MyForm.OnFormClose := ParentCloseRoutine" action so that
I know the form was closed, but I don't know where in the lifetime of the object
that comes. In Delphi there is a "release" or something that ensures it is free'd
when all the calls have completed. Something like that would be good, but you need
to know the "global" pointer to the form is nil too.

/Matthew Jones/
Thu, Jun 20 2013 2:52 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Christian,

<< I tried this:

procedure TMyForm.FMyFormDlgClose(Sender: TObject);
begin
 TForm(Sender).Free;
end;

it seems to work, but is this really a good way to do it? >>

Yep, that's what the framework does for message dialogs:

procedure TDesktop.DoMsgDlgClose(Sender: TObject);
begin
  try
     TMsgDlgForm(Sender).DoResult(TMsgDlgForm(Sender).ModalResult);
  finally
     TMsgDlgForm(Sender).Free;
  end;
end;

Tim Young
Elevate Software
www.elevatesoft.com
Image