bool FrameworkView::EnsureAutomationProviderCreated() { #ifdef ACCESSIBILITY if (!mWidget || mShuttingDown) return false; if (mAutomationProvider) { return true; } Accessible *rootAccessible = mWidget->GetRootAccessible(); if (rootAccessible) { IInspectable* inspectable; HRESULT hr; AssertRetHRESULT(hr = UIABridge_CreateInstance(&inspectable), hr); // Addref IUIABridge* bridge = nullptr; inspectable->QueryInterface(IID_IUIABridge, (void**)&bridge); // Addref if (bridge) { bridge->Init(this, mWindow.Get(), (ULONG)rootAccessible); mAutomationProvider = inspectable; inspectable->Release(); return true; } } #endif return false; }
//------------------------------------------------------------------- // GetFloatProperty // //------------------------------------------------------------------- float CObjectFinderEffect::GetFloatProperty( Microsoft::WRL::ComPtr<ABI::Windows::Foundation::Collections::IMap<HSTRING, IInspectable *>> &spSetting, const HSTRING &key, boolean &found) { float value = 0.0f; spSetting->HasKey(key, &found); IInspectable* valueAsInsp = NULL; if (found) { spSetting->Lookup(key, &valueAsInsp); } if (valueAsInsp) { Microsoft::WRL::ComPtr<ABI::Windows::Foundation::IPropertyValue> pPropertyValue; HRESULT hr = valueAsInsp->QueryInterface(IID_PPV_ARGS(&pPropertyValue)); if (!FAILED(hr)) { hr = pPropertyValue->GetSingle(&value); } } return value; }
HRESULT TestJson() { HRESULT hr; HSTRING className; IfFailedReturn(WindowsCreateString( RuntimeClass_Windows_Data_Json_JsonObject, wcslen(RuntimeClass_Windows_Data_Json_JsonObject), &className)); IInspectable* inspectable; IfFailedReturn(RoActivateInstance(className, &inspectable)); ULONG iidCount; IID* iids; IfFailedReturn(inspectable->GetIids(&iidCount, &iids)); wprintf(L"Iids: %d\r\n", iidCount); IJsonValue* jsonValue; IfFailedReturn(inspectable->QueryInterface(__uuidof(jsonValue), reinterpret_cast<void**>(&jsonValue))); HSTRING jsonString; IfFailedReturn(jsonValue->Stringify(&jsonString)); // TODO: Confirm that length parameter is required. I heard it is needed beacuase it is not guaranteed that the // PCWSTR will end on null character. UINT32 length; const wchar_t* rawJsonString; rawJsonString = WindowsGetStringRawBuffer(jsonString, &length); wprintf(L"Stringify: %s \r\nlength: %d\r\n", rawJsonString, length); IfFailedReturn(WindowsDeleteString(className)); IfFailedReturn(WindowsDeleteString(jsonString)); return S_OK; }
void D2DComponent::CreateDeviceIndependentResources() { IInspectable* sisInspectable = (IInspectable*) reinterpret_cast<IInspectable*>(this); ThrowIfFailed(sisInspectable->QueryInterface(__uuidof(ISurfaceImageSourceNative), (void **)&_sisNative)); }