Win32 API 日本語リファレンス
ホームSystem.WinRT › ISpatialInteractionManagerInterop

ISpatialInteractionManagerInterop

COM
IID5c4ee536-6a98-4b86-a170-587013d6fd4b継承元IInspectable自前メソッド開始 vtbl6

公式ドキュメント

WinRT の SpatialInteractionManager オブジェクトとの相互運用を可能にし、手、モーションコントローラー、システム音声コマンドからのユーザー入力にアクセスするための SpatialInteractionManager のメンバーへのアクセスを提供します。

メソッド 1

vtbl = vtable インデックス(0始まり)。HSP等からCOMメソッドをインデックス指定で呼ぶ際に使用します。0〜2 は IUnknown。

vtbl 6 HRESULT GetForWindow(HWND window, GUID* riid, void** spatialInteractionManager)

アクティブなアプリケーションにバインドされた SpatialInteractionManager オブジェクトを取得します。

windowHWNDinアクティブなアプリケーションのウィンドウへのハンドル。
riidGUID*inSpatialInteractionManager オブジェクトの GUID。
spatialInteractionManagervoid**outSpatialInteractionManager オブジェクトへのポインターのアドレス。

戻り値

型: HRESULT

この関数が成功した場合は S_OK を返します。それ以外の場合は HRESULT エラーコードを返します。

解説(Remarks)

次の例は、ISpatialInteractionManagerInterop::GetForWindow を使用して HWND に対応する SpatialInteractionManager を取得し、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>();
}
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

HSP用 COM定義

#usecom / #comfunc によるHSPのCOM呼び出し定義。数字は vtbl インデックス(0始まり)。クラスIDが無い場合 #usecom の末尾は "{}"、ある場合は "{CLSID}"

出力引数:
#define global IID_ISpatialInteractionManagerInterop "{5C4EE536-6A98-4B86-A170-587013D6FD4B}"
#usecom global ISpatialInteractionManagerInterop IID_ISpatialInteractionManagerInterop "{}"
#comfunc global ISpatialInteractionManagerInterop_GetForWindow  6 sptr,var,sptr
; ※数字は vtbl インデックス(0始まり)。0/1/2 は IUnknown(QueryInterface/AddRef/Release)。
; ※このインターフェースは直接 CoCreateInstance するクラスIDが無いため "{}"(他メソッド/アクティベーションで取得)。
; ※出力/バッファ引数は var(変数直渡し)。varptr 方式にも切替可。
; ※ハンドル/void*等の不透明ポインタは IronHSP では intptr 指定が可能。