How to detect if a messagedlg is showing? lazarus / 31-LCL ---------------------------------------------------------------------- Bart · 2020-07-09 11:11 Hi, When my app fires an event, I need to know if at that time I have a MessageDlg (or some other system dialog) open. How to figure that out? Bart ---------------------------------------------------------------------- 440bx · 2020-07-09 11:34 Quote from: Bart on July 09, 2020, 01:11:45 pmWhen my app fires an event, I need to know if at that time I have a MessageDlg (or some other system dialog) open. How to figure that out? Presuming your question is on Windows and that the MessageDlg is owned by your application (not the desktop for instance), one fairly simple way is to enumerate the windows owned by your app.  There is usually a piece of information you can obtain using the window handle that will allow you to identify a dialog.  HTH. ---------------------------------------------------------------------- korba812 · 2020-07-09 11:41 Maybe TScreen.Forms property will be useful in this case. https://lazarus-ccr.sourceforge.io/docs/lcl/forms/tscreen.forms.html ---------------------------------------------------------------------- winni · 2020-07-09 11:45 Hi! Yes - use TScreen. There is Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function GetCurrentModalForm: TCustomForm; Winni ---------------------------------------------------------------------- ASerge · 2020-07-09 13:42 Quote from: Bart on July 09, 2020, 01:11:45 pmWhen my app fires an event, I need to know if at that time I have a MessageDlg (or some other system dialog) open. Application dialogs - by (Application.ModalLevel > 0). System dialogs - using System API. ---------------------------------------------------------------------- Bart · 2020-07-09 16:49 Quote from: winni on July 09, 2020, 01:45:16 pmThere is Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function GetCurrentModalForm: TCustomForm; That simply returns nil, wether or not I have a MessageDlg() showing. Bart ---------------------------------------------------------------------- Bart · 2020-07-09 16:52 Quote from: 440bx on July 09, 2020, 01:34:29 pmPresuming your question is on Windows ... I'ld prefer a cross platform solution, I use that app on both Windows and Linux. Quote from: 440bx on July 09, 2020, 01:34:29 pm... and that the MessageDlg is owned by your application (not the desktop for instance) The MesssageDlg is just that: a call to the function MessageDlg(), GOK if the resulting form/dialog is owned by me or by some other "thing" in my system. Bart ---------------------------------------------------------------------- Bart · 2020-07-09 16:53 Quote from: ASerge on July 09, 2020, 03:42:32 pmApplication dialogs - by (Application.ModalLevel > 0). System dialogs - using System API. My fault: I mean the dialog shown by MessageDlg() or ShowMessage() functions. Bart ---------------------------------------------------------------------- ASerge · 2020-07-09 16:57 Quote from: Bart on July 09, 2020, 06:53:52 pmQuote from: ASerge on July 09, 2020, 03:42:32 pmApplication dialogs - by (Application.ModalLevel > 0). System dialogs - using System API. My fault: I mean the dialog shown by MessageDlg() or ShowMessage() functions. So Application.ModalLevel > 0. ---------------------------------------------------------------------- Bart · 2020-07-09 17:13 Quote from: ASerge on July 09, 2020, 06:57:39 pmQuote from: Bart on July 09, 2020, 06:53:52 pmQuote from: ASerge on July 09, 2020, 03:42:32 pmApplication dialogs - by (Application.ModalLevel > 0). System dialogs - using System API. My fault: I mean the dialog shown by MessageDlg() or ShowMessage() functions. So Application.ModalLevel > 0. Yep, that seems to work! Bart