SetActiveWindow

  HWND SetActiveWindow(hwnd)    
  HWND hwnd; /* handle of window to activate */

The SetActiveWindow function makes the given top-level window the active window.

Parameters

hwnd

Identifies the top-level window to activate.

Return Value

The return value identifies the window that was previously active.

Comments

The SetActiveWindow function should be used with care since it allows an application to arbitrarily take over the active window and keyboard focus. Normally, Windows takes care of all activation.

If the window identified by the hwnd parameter was created by the calling thread, the active window status of the calling thread is set to hwnd. Otherwise, the active window status of the calling thread is set to NULL, and the active window status of the thread that created the window is set to hwnd.

See Also

GetActiveWindow, WM_ACTIVATE