Page 1 of 1
ModalResult value changes during closing process
Posted: Thu Dec 30, 2021 11:35 am
by MiMi
Hello!
I'm using the SimpleBrowser demo (from release 87.0.4280.141)
I've added a form that merely opens the SimpleBrowser form with ShowModal
In TFormSimpleBrowser I've added a button that sets its ModalResult to mrOk
When I press the button, ModalResult is set to mrOk but it is changed during the closing process of SimpleBrowser
Following this sequence:
FormCloseQuery : ModalResult = mrOk
ChromiumWindow1Close : ModalResult = mrNone
FormCloseQuery : ModalResult = mrCancel
Why?
Thanks in advance for any help or tips
Re: ModalResult value changes during closing process
Posted: Sun Jan 02, 2022 11:44 am
by salvadordf
Hi,
The source code in CEF4Delphi doesn't modify the ModalResult property.
The VCL code in "Vcl.Forms.pas" on the other hand changes the TCustomForm.ModalResult value several times :
- TCustomForm.Close
- TCustomForm.CloseModal
- TCustomForm.ShowModal
ChromiumWindow1Close is executed asynchronously and it can happen after the VCL code sets ModalResult to 0, which is equivalent to mrNone.
Re: ModalResult value changes during closing process
Posted: Mon Jan 03, 2022 9:53 am
by MiMi
Thank you very much for your answer!
The source code in CEF4Delphi doesn't modify the ModalResult property.
ikr but maybe cef does...
Because if I remove the call to:
Code: Select all
ChromiumWindow1.CloseBrowser(True);
then ModalResult isn't changed
The VCL code in "Vcl.Forms.pas" on the other hand changes the TCustomForm.ModalResult value several times
Yes but "Vcl.Forms.pas" doesn't alter TCustomForm.ModalResult final value if it was set on purpose by the user
My problem is that I cannot use a Yes-No dialog and get the correct answer in a form that has Chromium browser with your recommended closing process
Re: ModalResult value changes during closing process
Posted: Mon Jan 03, 2022 11:35 am
by salvadordf
The browser destruction cancels the first form close to close the browser properly and then retries closing the form.
Perhaps the VCL code resets the ModalResult value after the first step.
Save the ModalResult value before cancelling the form closure.
Re: ModalResult value changes during closing process
Posted: Tue Jan 04, 2022 8:09 am
by MiMi
Thanks!
Save the ModalResult value before cancelling the form closure.
This is what I've already done to fix it but I wanted to be sure that I wasn't missing something obvious...