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.