views:

753

answers:

2

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  A: 

Assuming you're using Windows Forms, you can handle the OnSizeChanged event, and test the WindowState

Traveling Tech Guy
+5  A: 

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).

MusiGenesis
What I'm trying to make, is a sort of virtual dekstop manager (actually an illusion of it) where I keep track of every open window handle and when switching from desktop to desktop I minimize/restore the corresponding windows. With this approach I foresee that down the road I will need to know If a window gets minimized/restored by the user so conflicts don't appear.
Gabriel