Mikulas Dite
Mikulas Dite

Reputation: 7941

Focus hWnd of another application

Is it possible to change focus inside a different application? I'm talking about the distinct views (data lists, custom views), not main windows. These also have handles, spy++ shows them properly and stuff, but when I've tried setting SetFocus(), is was no good. Does SetFocus() only work for main windows or what is amiss? Thanks

Upvotes: 1

Views: 244

Answers (1)

Hans Passant
Hans Passant

Reputation: 942518

From the MSDN article:

The window must be attached to the calling thread's message queue

You'll need AttachThreadInput() first. GetWindowThreadProcessId() to get the thread that owns the window.

Upvotes: 1

Related Questions