AllowSetForegroundWindow

The AllowSetForegroundWindowfunction enables the specified process to set the foreground window using the SetForegroundWindow function. The calling process must already be able to set the foreground window. For more information, see Remarks later in this topic.

Syntax,Remarks,

Syntax

BOOL AllowSetForegroundWindow(
DWORD dwProcessId);Parameters
dwProcessId[in] Specifies the identifier of the process that will be enabled to set the foreground window. If this parameter is ASFW_ANY, all processes will be enabled to set the foreground window. Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. The function will fail if the calling process cannot set the foreground window. To get extended error information, call GetLastError.

Remarks

Starting with Microsoft Windows 98 and Windows 2000, the system restricts which processes can set the foreground window. A process can set the foreground window only if one of the following conditions is true:
The process is the foreground process. The process was started by the foreground process. The process received the last input event. There is no foreground process. The foreground process is being debugged. The foreground is not locked (see LockSetForegroundWindow). The foreground lock time-out has expired (see SPI_GETFOREGROUNDLOCKTIMEOUT in SystemParametersInfo). Windows 2000/XP:No menus are active.
A process that can set the foreground window can enable another process to set the foreground window by calling AllowSetForegroundWindow. The process specified by dwProcessIdloses the ability to set the foreground window the next time the user generates input, unless the input is directed at that process, or the next time a process calls AllowSetForegroundWindow, unless that process is specified.
Windows 95/98/Me:This function is not implemented. Therefore, processes must cooperate to manage the foreground window. For example, an application may wish to support only one instance. When the second instance starts up, it should detect the previous instance and call SetForegroundWindowon the window of the previous instance. It should not post a message to the window of the previous instance asking it to call SetForegroundWindowon itself, because the previous instance will not necessarily have permission to call SetForegroundWindow.
Function Information
Minimum DLL Version
user32.dll
Header
Declared in Winuser.h, include Windows.h
Import library
User32.lib
Minimum operating systems
Windows Me, Windows 2000
See Also
Windows Overview, LockSetForegroundWindow, SetForegroundWindow.

相關詞條

熱門詞條

聯絡我們