Recent

Author Topic: [solved]ModalResult not recognized  (Read 741 times)

Zvoni

  • Hero Member
  • *****
  • Posts: 3007
[solved]ModalResult not recognized
« on: February 24, 2022, 10:53:47 am »
Hi Folks,

i'll bite.
See attached project.
Form1 calls Form2.
On Form2 are 2 Buttons.
I set ModalResult at Form2-Creation to mrCancel.
Only Button1 sets ModalResult to mrOK.
This way i thought to catch all 3 possible ways to close Form2:
1) Button1 (=OK)
2) Button2 (=Cancel)
3) the red X in the Upper Right corner of the Window
Closing (actually Hiding!) Form2 returns mrCancel everytime, which i only expected for 2)+3)

Note: this is of course a stripped down example.
In my actual project i'm setting some Properties of Form2, which, after Form2 gets hidden, i read out in Form1 and go from there
(classic "Child is not updating the Parent, but the Parent pulls from Child").
from Form1 i close and then Free Form2

Huh?

EDIT: You gotta be kidding me....
https://forum.lazarus.freepascal.org/index.php?topic=20320.0
Setting ModalResult stops the Modal loop?
OK, using now my own Property on Form2 to indicate how Form was closed/hidden
« Last Edit: February 24, 2022, 11:20:47 am by Zvoni »
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

 

TinyPortal © 2005-2018