Compartilhar via


SetForegroundWindow (Windows Embedded CE 6.0)

1/6/2010

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

Syntax

BOOL SetForegroundWindow(
  HWND hWnd 
);

Parameters

  • hWnd
    [in] Handle to the window that should be activated and brought to the foreground. For more information, see the Remarks section.

Return Value

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

Remarks

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.

If the window being set to the foreground is minimized, the window may not be visible to the end user. To restore the window to a visible state, ShowWindow should be called.

This function does not reactivate the last active owned window by default. To ensure that the last active owned window is reactivated, combine the window handle with 0x01 using the logical OR operator. For example:

SetForegroundWindow((HWND)(((ULONG) hwnd) | 0x01) );

Calling PeekMessage before the top level window of an application is created will result in the window being created at the back of the z-order. You will need to explicitly call SetForegroundWindow to show the window when it is created after a call to PeekMessage. If the application already has a window in the foreground, then the new window will be created in the foreground.

SetForegroundWindow should not be called on child windows.

Requirements

Header winuser.h
Windows Embedded CE Windows CE 1.0 and later

See Also

Reference

Windows Functions
GetForegroundWindow
SetActiveWindow