I need a help ...
I have two separated modal forms in Delphi VCL Forms application. Based on the solution from: How can I make a form that is not disabled when another form is shown modally?
I use EnableWindow(Self.Handle, True)
and it works perfect: I can open and edit the first form and without closing it, open the second form. Both are active and editable.
The problem starts when I try to close first modal form without closing the second. It waits until the second one is closed.
Does exist any way to forced closing the first modal form (except the Self.Free because I need some information from model form in parent form) having the second one still open?
The code is quite simple:
Main form (with Button1):
procedure TfrMainForm.WMEnable(var _Msg: TWMEnable);
begin
inherited;
if not _Msg.Enabled and (Application.ModalLevel > 0) then Begin
EnableWindow(Self.Handle, True);
End;
end;
procedure TfrMainForm.Button1Click(Sender: TObject);
Var
tmpSubForm: TfrSubForm;
begin
tmpSubForm := TfrSubForm.Create(Self);
Try
tmpSubForm.ShowModal;
//get some information from tmpSubForm
Finally
tmpSubForm.Free;
End;
end;
"Child" form (do nothing - only open):
procedure TfrSubForm.WMEnable(var _Msg: TWMEnable);
begin
inherited;
if not _Msg.Enabled and (Application.ModalLevel > 0) then Begin
EnableWindow(Self.Handle, True);
End;
end;