This function puts the thread that created the specified window into the foreground and activates the window.

BOOL SetForegroundWindow(
HWND hWnd ); 


  • hWnd
    [in] Handle to the window that should be activated and brought to the foreground.

Return Values

Nonzero indicates that the window was brought to the foreground. Zero indicates that the window was not brought to the foreground.


The foreground window is the window at the top of the z-order. It is the window that the user is working with. In a preemptive multitasking environment, you should generally let the user control which window is the foreground window.

The thread that owns the window is not given a priority boost.


Runs on Versions Defined in Include Link to
Windows CE OS 1.0 and later Winuser.h    

Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

GetForegroundWindow, SetActiveWindow

 Last updated on Tuesday, July 13, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.