Reputation: 5478
I have a timer in the main application form.
The timer displays a nag screen every N seconds.
But I'd like to avoid showing the nag screen if any modal dialog windows are open. Otherwise overlapping will occur.
I can use Application.OpenForms
, but this doesn't count dialogs such as OpenFileDialog
.
How to detect if any child dialogs are currently shown?
Upvotes: 0
Views: 1249
Reputation: 27913
Consider using these Win32 apis:
GetForegroundWindow();
GetAncestor(foregroundWindow, GA_ROOTOWNER);
GetWindowThreadProcessId(foregroundWindow, out activeProcessId)
Upvotes: 2