I have a main form (A) that call a modal form (B). and (B) call another modal form (C) and they work normal
the problem when I added new modal form (D) and make it called from (B) then when I close the form (D) the form (B) also closed !! although I made sure the close button modal result = mrnone
please advise
Code:
Form A calling B
B := TB.Create(self);
B.ShowModal;
Form B Calling C
C := TC.Create(self);
C.ShowModal;
Form B Calling D
D := TD.Create(self);
D.ShowModal;
I use Delphi 2010
More Code added
this is how I free the form that cause the problem and make the caller close !
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
action := cafree;
end;
procedure TForm2.FormDestroy(Sender: TObject);
begin
Form2 := nil;
end;
This is how I show the modal form
procedure Tmymodalfrm.Button1Click(Sender: TObject);
begin
form2 := Tform2.Create(self);
form2.ShowModal;
end;
And after tracing with the call stack I get the code that originally created form B which is so normal:
B := TB.Create(self);
B.ShowModal;
and I am going crazy soon 🙂
Found the problem. the button that call the form has a modal result = mrclose !!