31.1.6 Functions Affected by Localized Input State

These functions are affected by localized input state. Please refer to the programmers reference for complete descriptions of these functions.

SetFocus,
GetFocus,
SetActiveWindow,
GetActiveWindow,
GetCapture,
SetCapture,
ReleaseCapture

As a general description, the `get' functions will query only local current thread state. The `set' functions set state local to the window creator thread. If the current thread did not create the passed window, then the current thread's related input state will get set to NULL as if the input related state where being transferred between threads.

This slightly changes the Win3 semantics of functions that return input-synchronized state. For example this means SetFocus can be called with a hwnd and return TRUE for success, but a followup call to GetFocus might return NULL. More substantially, GetFocus will now return NULL if the calling thread does not have a focus window, where under Win3 GetFocus almost never returns NULL because some window in the system usually has the keyboard focus.

Mouse capture is affected in an added dimension. The Win32 server input thread cannot know ahead of time when an input thread is going to set the capture and when it isn't. Also, regardless of the input state of any application, the system must allow the user to direct input to any other application at any time. Therefore, the semantics of mouse capture change slightly.

The semantics of how and when the capture changes are not affected; how and when an application gets mouse input is affected. The Win32 server will send all mouse input between a mouse down operation and a mouse up operation to the queue of the thread that created the window the original mouse down went into. This will allow the input thread to perform mouse capture processing as the input is read out of the queue. This means that if the mouse button is down during the mouse capture, the capture window will see all input generated by the mouse, no matter where the mouse is on the screen, until the mouse button goes up or the mouse capture is released. This also means that if a thread sets the mouse capture while the mouse button is up, the mouse capture window will see mouse events only as long as the mouse is over a window that thread created.