Beispiel #1
0
HRESULT AccessibleObject::GetRole(std::wstring& role, long child_id,
                                  IAccessible* acc) {
  DWORD role_id = 0;

  HRESULT hr = GetRole(role_id, child_id, acc);

  if (hr != S_OK)
    return hr;

  UINT role_length = GetRoleText(role_id, nullptr, 0);
  LPTSTR buffer = (LPTSTR)malloc((role_length + 1) * sizeof(TCHAR));

  if (buffer != nullptr) {
    GetRoleText(role_id, buffer, role_length + 1);
    if (buffer) {
      role = buffer;
    } else {
      role.clear();
    }
    free(buffer);
  } else {
    return E_OUTOFMEMORY;
  }

  return S_OK;
}
Beispiel #2
0
void get_role(long childId, IAccessible *pAccessible, char *itemText) {
	long role ;

	if (get_role(childId, pAccessible, &role) == S_OK) {
		int roleTextMax = 255 ;
		LPTSTR pRoleText = new TCHAR[roleTextMax] ;
		GetRoleText(role, pRoleText, roleTextMax) ;

		int lenSzRoleText = 255 ;
		char *pszRoleText = new char[lenSzRoleText] ;
		WideCharToMultiByte(CP_ACP, 0, pRoleText, wcslen(pRoleText) + 1, pszRoleText, lenSzRoleText, NULL, NULL) ;

		sprintf(itemText, "0x%x, %s", role, pszRoleText) ;
	}
}
Beispiel #3
0
// Get info for a child (id > 0) or object (id == 0)
void MyFrame::GetInfo(IAccessible* accessible, int id, wxString& name, wxString& role)
{
    VARIANT var;
    VariantInit(& var);
    var.vt = VT_I4;
    var.lVal = id;

    BSTR bStrName = 0;
    HRESULT hResult = accessible->get_accName(var, & bStrName);

    if (hResult == S_OK)
    {
        name = wxConvertStringFromOle(bStrName);
        SysFreeString(bStrName);
    }
    else
    {
        name = wxT("NO NAME");
    }

    VARIANT varRole;
    VariantInit(& varRole);

    hResult = accessible->get_accRole(var, & varRole);

    if (hResult == S_OK && varRole.vt == VT_I4)
    {
        wxChar buf[256];
        GetRoleText(varRole.lVal, buf, 256);

        role = buf;
    }
    else
    {
        role = wxT("NO ROLE");
    }
}