ISpatialInteractionManagerInterop::GetForWindow method (spatialinteractionmanagerinterop.h)
Retrieves a SpatialInteractionManager object bound to the active application.
Syntax
HRESULT GetForWindow(
[in] HWND window,
[in] REFIID riid,
[out] void **spatialInteractionManager
);
Parameters
[in] window
Type: HWND
Handle to the window of the active application.
[in] riid
Type: REFIID
The GUID of the SpatialInteractionManager object.
[out] spatialInteractionManager
Type: void**
Address of a pointer to a SpatialInteractionManager object.
Return value
Type: HRESULT
If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
Remarks
This example shows how to retrieve a SpatialInteractionManager by using ISpatialInteractionManagerInterop::GetForWindow to retrieve the SpatialInteractionManager for an HWND.
// 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>();
}
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 10, version 1703 [desktop apps only] |
Minimum supported server | None supported |
Target Platform | Windows |
Header | spatialinteractionmanagerinterop.h |