Setting ModalResult does not close a Modal dialog..


I show a form with Form.ShowModal. The form has two buttons with ModalResult mrOK and mrCancel respectively. (this is very standard stuff..)

This worked fine in the past to close the dialog, now for some strange reason clicking on the button simply does nothing.

If I change the ModalResult to mrNone, and instead add event handler

procedure TShortCutsForm.btnOKClick(Sender: TObject);
  ModalResult := mrOK;

Again, nothing happens.

Any ideas what is happening? Why Modal form is not closing when ModalResult is set?

This was working fine, now suddenly stopped working. I'm using Tokyo 10.2.3



No Data
  • Thanks people for the suggestions.

    I did find the cause of the problem. Nothing wrong in the code for the modal dialog. Before showing the Modal I create a TFrame and then Free it (for some related purpose). Recently I added code to create a Thread in the Frame. What is happening is that the Thread terminates after the TFrame has been freed.

    If I make some changes to what is called before I show the Modal Dialog, then indeed an error comes up. However, as things were, no error occurs (even when running in the IDE). However it seems that there is some internal error that blocks the Dialog from closing..