Eloff
Eloff

Reputation: 21666

How to activate a window of an external application

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?

Upvotes: 3

Views: 2987

Answers (2)

Adrian McCarthy
Adrian McCarthy

Reputation: 47962

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.

Upvotes: 3

karlphillip
karlphillip

Reputation: 93410

FindWindow() followed by ShowWindow().

Upvotes: 0

Related Questions