I've got a timer running in my Delphi MDI application and I'd like to use it to pop up a message if something changes in the background. But I don't want that message to pop up when the the application has a modal dialog in the foreground because the user couldn't do anything about it.
So what I'd like to know is how can I check for the existence of a modal dialog in my application?
You could try with this code:
var
ActForm: TCustomForm;
begin
ActForm := Screen.ActiveForm;
if (ActForm = nil) or not (fsModal in ActForm.FormState) then begin
end;
end;
I tested with Delphi 4, works for me.
[EDIT]: But you should really think about whether popping up a form and stealing focus is a good idea. It depends on your application, but if a user is currently entering something into an edit field, or doing something with the mouse, then this might break their workflow.