Skip to main content

SetForegroundWindow

Set a window into the foreground and activate the window.

void SetForegroundWindow();

Parameters

None

Remarks

For some windows this action may result in the icon in the taskbar flashing to indicate use attention is required rather than putting the window at the top of the Z-order. To put a top level window into the foreground, use ShowWindow.

Example

notepadWindow = FindTopWindow("Untitled - Notepad"); // find the top level window
notepadWindow.SetForegroundWindow(); // this will ensure the window is in the foreground and activated

Related: