From: Connor McAdams cmcadams@codeweavers.com
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/uiautomationcore/tests/uiautomation.c | 5 ++--- dlls/uiautomationcore/uia_provider.c | 24 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/dlls/uiautomationcore/tests/uiautomation.c b/dlls/uiautomationcore/tests/uiautomation.c index 009864d10c7..beb34fb400f 100644 --- a/dlls/uiautomationcore/tests/uiautomation.c +++ b/dlls/uiautomationcore/tests/uiautomation.c @@ -12347,9 +12347,8 @@ static void test_node_hwnd_provider_(HUIANODE node, HWND hwnd, const char *file, GetClassNameW(hwnd, buf, ARRAY_SIZE(buf)); hr = UiaGetPropertyValue(node, UIA_ClassNamePropertyId, &v); ok_(file, line)(hr == S_OK, "Unexpected hr %#lx\n", hr); - todo_wine ok_(file, line)(V_VT(&v) == VT_BSTR, "Unexpected VT %d\n", V_VT(&v)); - if (V_VT(&v) == VT_BSTR) - ok(!lstrcmpW(V_BSTR(&v), buf), "Unexpected BSTR %s\n", wine_dbgstr_w(V_BSTR(&v))); + ok_(file, line)(V_VT(&v) == VT_BSTR, "Unexpected VT %d\n", V_VT(&v)); + ok(!lstrcmpW(V_BSTR(&v), buf), "Unexpected BSTR %s\n", wine_dbgstr_w(V_BSTR(&v))); VariantClear(&v); winetest_pop_context();
diff --git a/dlls/uiautomationcore/uia_provider.c b/dlls/uiautomationcore/uia_provider.c index afc44fe45ac..9c9ad2a426e 100644 --- a/dlls/uiautomationcore/uia_provider.c +++ b/dlls/uiautomationcore/uia_provider.c @@ -1202,6 +1202,16 @@ HRESULT WINAPI UiaProviderFromIAccessible(IAccessible *acc, long child_id, DWORD return S_OK; }
+static HRESULT uia_get_hr_for_last_error(void) +{ + DWORD last_err = GetLastError(); + + if (last_err == ERROR_INVALID_WINDOW_HANDLE) + return UIA_E_ELEMENTNOTAVAILABLE; + + return E_FAIL; +} + /* * Default ProviderType_BaseHwnd IRawElementProviderSimple interface. */ @@ -1304,6 +1314,20 @@ static HRESULT WINAPI base_hwnd_provider_GetPropertyValue(IRawElementProviderSim break; }
+ case UIA_ClassNamePropertyId: + { + WCHAR buf[256] = { 0 }; + + if (!GetClassNameW(base_hwnd_prov->hwnd, buf, ARRAY_SIZE(buf))) + hr = uia_get_hr_for_last_error(); + else + { + V_VT(ret_val) = VT_BSTR; + V_BSTR(ret_val) = SysAllocString(buf); + } + break; + } + default: break; }