的WinForms:有没有一种方法,只要一个形式获取我的应用程序中打开被告知? [英] Winforms: Is there a way to be informed whenever a form gets opened in my application?

查看:150
本文介绍了的WinForms:有没有一种方法,只要一个形式获取我的应用程序中打开被告知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个切换到窗口按钮,在我的主要形式,我想启用只有当其他的窗口(在我的应用程序)是开放的。是否有某种事件,每当一个形式打开或关闭,我的主要形式可以挂钩所引发? (例如,也许某种方法来跟踪时Application.OpenForms已经改变?)

I have a "Switch to window" button on my main form that I'd like to be enabled only when other windows (in my app) are open. Is there some sort of event that is raised whenever a form is opened or closed that my main form can hook? (For example, perhaps some sort of way to track when Application.OpenForms has changed?)

(我的理解是,如果该功能是在一个菜单项,我可以简单地做Application.OpenForms检查菜单被点击的时候,但是这个按钮在菜单中。)

(I understand that if this functionality were in a menu item, I could simply do the Application.OpenForms check when the menu was clicked, but this button is not in a menu.)

推荐答案

您可以使用的的MessageFilter 并监控WM_SHOWWINDOW和WM_CLOSE消息。

You could use a MessageFilter and monitor for WM_SHOWWINDOW and WM_CLOSE messages.

这篇关于的WinForms:有没有一种方法,只要一个形式获取我的应用程序中打开被告知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆