Delphi IAccessible Get_accState influences Get_accName?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-08 02:15:22

问题


I'm currently adding the IAccessible-Interface to my derived VCL-Components to be able to implement automated UI-Testing for my application.

After implementing the interface i didnt see the name in the properties of my components read out via external tools, though i saw while debugging it was set. After "some" (or more likely very much) testing around i found out, that the return value of Get_accState seems to be influencing the name:

When I return S_OK in this function (independet from the State i set), my Control name is empty, else it's the value set in Get_accName.

Am I doing something wrong? Why does this happen? To me it seems like a bug of MSAA, though this is unlikely...


This is the function setting the name:

function TXControlEigenschaften.Get_accName(varChild: OleVariant; out pszName: WideString): HResult;
begin
  pszName := '';
  Result := ValidateChildId(varChild);
  if Result = S_OK then
  begin
    if AccessibleName <> '' then
      pszName := AccessibleName
    else
      pszName := FControl.Name;
  end;
end;

When I do it like this, the name is there:

function TXControlEigenschaften.Get_accState(varChild: OleVariant;
  out pvarState: OleVariant): HResult;
begin
  Result := DISP_E_MEMBERNOTFOUND;
end;

But when it's like this, how I want it to be, the name is empty:

function TXControlEigenschaften.Get_accState(varChild: OleVariant;
  out pvarState: OleVariant): HResult;
begin
  Result := ValidateChildId(varChild);
    if Result = S_OK then
      pvarState := STATE_SYSTEM_FOCUSED;
end;

I'd even leave it like this, if there wouldn't be a problem with selecting the components via UI-Test Recorders when the state isn't set properly.

来源:https://stackoverflow.com/questions/21908982/delphi-iaccessible-get-accstate-influences-get-accname

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!