Export (0) Print
Expand All
COM
Expand Minimize

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 codeDescription
S_OK

The method was successful.

E_INVALIDARG

The lpvReserved parameter is not NULL.

E_NOINTERFACE

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

Objbase.h

Library

Ole32.lib

DLL

Ole32.dll

See also

IForegroundTransfer

 

 

Community Additions

ADD
Show:
© 2014 Microsoft