问题
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
回答1:
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).
回答2:
Assuming you're using Windows Forms, you can handle the OnSizeChanged event, and test the WindowState
来源:https://stackoverflow.com/questions/1384161/net-c-window-minimize-event