Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi - detecting if my app has a modal dialog open

I have a Delphi 2006 app that pops up a modal alert dialog when an error condition is detected. As the check for the error condition is done in an idle handler, the dialog can pop up over the top of another modal dialog if that one happens to be displayed. This can lead to a confusing situation for the user where the application main form doesn't get focus after the alert dialog is closed because these is another obscured modal dialog.

What I would like to do is postpone the alert popups while the app has any Modal dialogs open.

I tried GetLastActivePopup (MyMainWindow.Handle) but it seems to return non-zero all the time.

like image 340
rossmcm Avatar asked Dec 29 '22 09:12

rossmcm


1 Answers

See TApplication.ModalLevel or the TApplication.OnModalBegin and TApplication.OnModalEnd events. Also see this question.

like image 95
Lars Truijens Avatar answered Dec 31 '22 12:12

Lars Truijens