.NET (C#) 窗口最小化事件
嘿,我真的被我的项目困住了......我需要知道任何打开的窗口何时被最小化/恢复并在我自己的应用程序中处理事件。有什么想法吗?
编辑: Musigenesis 是对的,我确实想知道其他应用程序何时最小化/恢复
Hey, I'm really stuck with my project here... I need to know when any open window has been minimized / restored and Handle the event in my own App. Any ideas?
Edit:
Musigenesis is right, i do want to know when OTHER applications are minimized/restored
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为您需要使用 SetWindowsHookEx Win32 API 函数(以及其他一些函数)。基本上,您将遍历操作系统中所有打开的窗口并挂钩它们的大小调整事件。
强制性评论:您确定需要这样做吗?虽然我认为这在理论上是可能的,但这听起来是一个非常糟糕的主意,并且与 Windows 中应用程序的行为方式背道而驰。
更新:我认为 Windows 中的“显示桌面”的工作方式有点像这样,只不过它会遍历所有打开的窗口,然后使用 SendMessage 将它们最小化(如果打开的话)(完全是我的猜测)。
更新 2:这是一项艰巨的任务,我很好奇如何做到这一点(我 100% 确信这是可能的)。我会密切关注这个问题,如果没有人在接下来的一两天内给出答案,我会再次发布它并提供赏金(你可以这样做,但你需要有一些您自己的声誉点可以作为赏金提供)。
I think you would need to use the SetWindowsHookEx Win32 API function (along with a few others). Basically, you would iterate through all open windows in the OS and hook into their resizing events.
Obligatory comment: are you sure you need to do this? While I think this is theoretically possible, it sounds like a pretty bad idea, and counter to the way applications in Windows are supposed to behave.
Update: I think "Show Desktop" in Windows works kind of like this, except that it iterates through all the open windows and then uses SendMessage to minimize them if open (total guess on my part).
Update 2: this is a tough one, and I'm very curious to know how this could be done (I'm 100% sure that it is possible). I'll keep an eye on this question, and if no one comes up with an answer in the next day or two, I'll post it again and offer a bounty on it (you could do that, but you need to have some reputation points of your own to offer as a bounty).
假设您使用的是 Windows 窗体,您可以处理
OnSizeChanged
事件,并测试WindowState
Assuming you're using Windows Forms, you can handle the
OnSizeChanged
event, and test theWindowState
// 希望这有帮助。
// 达里尔·H·巴塞特
// Hope this helps.
// Darryl H. Bassett