Export (0) Print
Expand All


Windows Mobile 6.5
A version of this page is also available for

This function makes the specified top-level window associated with the thread calling this function the active window.

HWND SetActiveWindow(
  HWND hWnd 


[in] Handle to the top-level window to be activated.

The handle to the window that was previously active indicates success. NULL indicates failure. To get extended error information, call GetLastError.

The SetActiveWindow function activates a window, but not if the application is in the background. The window will be brought into the foreground — the top of z-order — if the application is in the foreground when it sets the 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.

For Windows CE 2.10 and later, if you call this function with hWnd set to the handle of the child window, SetActiveWindow returns NULL and sets the extended error value to zero.

The SetForegroundWindow window function, on the other hand, activates a window and forces it into the foreground. An application should only call SetForegroundWindow if it needs to display critical errors or information that needs the user's immediate attention.

Windows Embedded CEWindows CE 1.0 and later
Windows MobileWindows Mobile Version 5.0 and later

Community Additions

© 2014 Microsoft