开发者

WinForms - detect if any dialog windows are open

开发者 https://www.devze.com 2023-03-12 07:22 出处:网络
I have a timer in the main application form. The timer displays a nag screen every N seconds. But I\'d like to a开发者_Python百科void showing the nag screen if any modal dialog windows are open. Oth

I have a timer in the main application form.

The timer displays a nag screen every N seconds.

But I'd like to a开发者_Python百科void 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?


Consider using these Win32 apis:

GetForegroundWindow();
GetAncestor(foregroundWindow, GA_ROOTOWNER);
GetWindowThreadProcessId(foregroundWindow, out activeProcessId)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号