ISpatialInteractionManagerInterop::GetForWindow 方法 (spatialinteractionmanagerinterop.h)

检索绑定到活动应用程序的 SpatialInteractionManager 对象。

语法

HRESULT GetForWindow(
  [in]  HWND   window,
  [in]  REFIID riid,
  [out] void   **spatialInteractionManager
);

参数

[in] window

类型:HWND

活动应用程序窗口的句柄。

[in] riid

类型: REFIID

SpatialInteractionManager 对象的 GUID。

[out] spatialInteractionManager

类型: void**

指向 SpatialInteractionManager 对象的指针的地址。

返回值

类型: HRESULT

如果此函数成功,则返回 S_OK。 否则,将返回 HRESULT 错误代码。

注解

此示例演示如何通过使用 ISpatialInteractionManagerInterop::GetForWindow 检索 HWNDSpatialInteractionManager 来检索 SpatialInteractionManager

// This code example depends on these headers.
// <SpatialInteractionManagerInterop.h>
// <Windows.UI.Input.Spatial.h>
// <winrt/Windows.UI.Input.Spatial.h>
 
// Create the window for the HolographicSpace.
hWnd = CreateWindowW(
    m_szWindowClass, 
    m_szTitle,
    WS_VISIBLE,
    CW_USEDEFAULT, 
    0, 
    CW_USEDEFAULT, 
    0, 
    nullptr, 
    nullptr, 
    hInstance, 
    nullptr);
 
if (!hWnd)
{
    winrt::check_hresult(E_FAIL);
}
 
{
    using namespace winrt::Windows::UI::Input::Spatial;
    winrt::com_ptr<ISpatialInteractionManagerInterop> spatialInteractionManagerInterop = 
        winrt::get_activation_factory<SpatialInteractionManager, ISpatialInteractionManagerInterop>();
 
    winrt::com_ptr<ABI::Windows::UI::Input::Spatial::ISpatialInteractionManager> spSpatialInteractionManager;
    winrt::check_hresult(spatialInteractionManagerInterop->GetForWindow(hWnd, __uuidof(ABI::Windows::UI::Input::Spatial::ISpatialInteractionManager), winrt::put_abi(spSpatialInteractionManager)));
 
    SpatialInteractionManager spatialInteractionManager = spSpatialInteractionManager.as<SpatialInteractionManager>();
}

要求

要求
最低受支持的客户端 Windows 10版本 1703 [仅限桌面应用]
最低受支持的服务器 无受支持的版本
目标平台 Windows
标头 spatialinteractionmanagerinterop.h

另请参阅