tags:

views:

43

answers:

2

I've used FindWindow to get a handle to a window of an external application. How can I use this handle to activate the window of the external application, if it is minimized or behind other applications on the windows desktop?

A: 

FindWindow() followed by ShowWindow().

karlphillip
I tried ShowWindow and BringWindowToTop with no success, do they work on the windows of external processes?
Eloff
As long as you have successfully retrieved a handle to that window.
karlphillip
+2  A: 

To prevent focus-stealing (or at least make accidental focus-stealing harder), Windows puts up some roadblocks to one process bringing another process's window to the top.

Check MSDN for SetForegroundWindow (especially in the Remarks section) and AllowSetForegroundWindow.

You should either send a message to the process to tell it to restore its own window, or that process has to explicitly allow your process to do this.

Adrian McCarthy
Thanks, that seems to be the problem right there.
Eloff