SetForegroundWindow

  BOOL SetForegroundWindow(hwnd)    
  HWND hwnd; /* window to bring to foreground */

The SetForegroundWindow function puts the thread that owns hwnd into the foreground. Keyboard input is directed to the window and various visual cues are changed for the user.

Parameters

hwnd

Identifies the window to bring to the foreground.

Return Value

The return value is TRUE if the function was successful, or FALSE if an error occurred. Use the GetLastError function to obtain extended error information.

Comments

If hwnd is on the current queue and that queue is in the foreground, using this function is identical to using the SetActiveWindow function. If the current queue is either the thread losing or receiving the foreground state, its state changes will happen inside the SetForegroundWindow function.

See Also

GetForegroundWindow