Modal Form

From: Mike Hubbard (mmhubbard_at_socal.rr.com)
Date: 10/30/03


Date: Wed, 29 Oct 2003 15:38:44 -0800

I have the following code:

procedure ShowSomeForm;
begin
  if Assigned(gSomeForm) then
  begin
    gSomeForm.ModalResult := mrOk;
    Application.ProcessMessages;
  end;
  gSomeForm := TSomeForm.Create(nil);
  try
    gSomeForm.ShowModal;
  finally
    FreeAndNil(gSomeForm);
  end;
end;

procedure TSomeForm.FormClose(Sender: TObject; var Action:
TCloseAction);
begin
  // free form
  Action := caFree;
  gSomeForm := nil;
end;

Why doesn't the FormClose event ever fire when gSomeForm.ModalResult
is set? The event fires if a button on the form is pressed whose
ModalResult property is set to mrOk.

Thanks.

Mike


Quantcast