BOOL AttachThreadInput(idAttach, idAttachTo, fAttach) | |||||
DWORD idAttach; | /* thread to attach | */ | |||
DWORD idAttachTo; | /* thread to attach to | */ | |||
BOOL fAttach; | /* attach or detach | */ |
idAttach
Identifies the thread that will be attached to another thread.
idAttachTo
Identifies the thread that will be attached to.
fAttach
If TRUE, the two threads will be attached. If FALSE, the threads are detached.
The return value is TRUE if the function was successful, or FALSE if an error occurred. To obtain extended error information, use the GetLastError function.
Normally windows created on different threads process input independently of each other. That is they have their own set of input state (focus, active, capture windows, keystate, queue status etc . . . ), and they are not synchronized with the input processing of other threads. By using this function, a thread can attach its input processing to other threads. This also allows the threads to share input state, so it can actually make SetFocus() calls to windows of different threads, and get keystate information. Normally these things are impossible.
GetCurrentThreadId, GetWindowThreadProcessId