CoAllowSetForegroundWindow function
Enables the COM server process called to take focus away from the client application by using the IForegroundTransfer interface. The COM client then yields the foreground window to the specified COM server process whose proxy is pUnk. Yielding the foreground window is useful when the client wants a window owned by the server process to take focus.
Syntax
HRESULT CoAllowSetForegroundWindow( _In_ IUnknown *pUnk, _In_ LPVOID lpvReserved );
Parameters
- pUnk [in]
-
A pointer to the IUnknown interface on the proxy of the COM server process. Therefore, when a method call is done, the foreground window can be replaced with one that the server owns instead of one owned by the client.
- lpvReserved [in]
-
This parameter is reserved and must be NULL.
Return value
This function can return the following values.
| Return code | Description |
|---|---|
|
The method was successful. |
|
The lpvReserved parameter is not NULL. |
|
The pUnk parameter does not support foreground window control. |
Remarks
The system restricts which processes can call the SetForegroundWindow and AllowSetForegroundWindow functions to set the foreground window. As a result, an application is blocked from stealing the focus from another application even when the user is interacting with it. CoAllowSetForegroundWindow enables a user that has a custom interface to get the same behavior that happens for OLE interfaces where a change of window is expected (primarily associated with linking and embedding).
Examples
The following example demonstrates how CoAllowSetForegroundWindow uses the IForegroundTransfer interface and its method AllowForegroundTransfer:
pUnk->QueryInterface(IID_IForegroundTransfer, (void**)&pft);
pft->AllowForegroundTransfer(NULL);
pft->Release();
Requirements
|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
|---|---|
|
Minimum supported server | Windows 2000 Server [desktop apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 5/16/2013