There are two forms.
In Form1, Form2 is created, and then Form2, closed with the TBitBtn button
Unit1 Module:
procedure TForm1.Button1Click(Sender: TObject); begin Form2 := TForm2.Create(self); Form2.ShowModal; if Form2.ModalResult = mrOK then begin showmessage('on Unit2 click "OK"'); end; Form2.Free; end;
Unit2 Module:
procedure TForm2.BitBtn1Click(Sender: TObject); begin if StrToInt(Edit1.Text) > 10 then begin ShowMessage('"true", exit from procedure"'); exit; end; end;
When you click a button, you must not close Form2 if the condition in unit2 is true.
Question:
Why with ModalResult: = mrOK (component “TBitBtn”) - Form2 - closes without responding to “exit”, and the execution of the code “ if Form2.ModalResult = mrOK then ” in Unit1 continues.
And how do I with “ModalResult: = mrOK”, if the condition is met, it’s certainly not to close?
You can certainly do the flags, but it's interesting all the same in this way