Accessibility and Delphi 7

442 views
Skip to first unread message

Jim Bretti

unread,
Jun 6, 2013, 9:50:58 AM6/6/13
to virtual-...@googlegroups.com
I have an app that I'm still compiling with Delphi 7, and having some virtual treeview accessibilty problems. (Virtual Treeview version 5.1.3)   I did some things to get it to work better, but I'd like to run this by the group.

First, it looks like in one of the previous releases of Virtual Treeview, a dependency on msaaintf.pas was removed.  msaaintf.pas contained a declaration for notifywinevent, which is apparently incorrect in Delphi 7 (see issue 319).  I was seeing access violations in my app on calls to notifywinevent.  This problem was corrected by updating VirtualTrees.pas to include the updated declaration.

This solved the access violations on notifywinevent calls, but screen readers did not read text in rows that had focus.  I noticed that the function WMGetObject in virtualtrees.pas contains a $if directive that requires compiler version 18 in order to make calls to LresultFromObject. 

procedure TBaseVirtualTree.WMGetObject(var Message: TMessage);
begin
  if GetAccessibilityFactory <> nil then
  begin
    // Create the IAccessibles for the tree view and tree view items, if necessary.
    if FAccessible = nil then
      FAccessible := GetAccessibilityFactory.CreateIAccessible(Self);
    if FAccessibleItem = nil then
      FAccessibleItem := GetAccessibilityFactory.CreateIAccessible(Self);
    if Cardinal(Message.LParam) = OBJID_CLIENT then
      {$if CompilerVersion >= 18}
      if Assigned(Accessible) then
        Message.Result := LresultFromObject(IID_IAccessible, Message.WParam, FAccessible)
      else
      {$ifend}
        Message.Result := 0;
  end;
end;

I removed the $if directive here, which caused my D7 app to start making the LresultFromObject calls.  With this change I needed to add the following in the consts section, at the top of virtualtrees.pas

{$if CompilerVersion<18}

IID_IAccessible: TGUID = '{618736E0-3C3D-11CF-810C-00AA00389B71}';

function LResultFromObject(const riid: TGUID; wParam: WPARAM; punk: IUnknown): LRESULT; stdcall; external 'oleacc.dll' name 'LresultFromObject';

{$ifend}


With these changes, I can arrow up and down in a virtual treeview control, and screen reader reads row with focus.


Would someone please take a look at this and see if I'm on the right track?  If the update is correct, could the fix be added to the next version of the component?


I'm still having trouble getting screenreader to read the 'checked' or 'unchecked' state of a row (the virtual treeview control in my app uses checkboxes).  I could use some help with that .....


Thanks

Jim

Mike Lischke

unread,
Jun 6, 2013, 10:20:49 AM6/6/13
to virtual-...@googlegroups.com

Hey Jim,

I have an app that I'm still compiling with Delphi 7, and having some virtual treeview accessibilty problems. (Virtual Treeview version 5.1.3)   I did some things to get it to work better, but I'd like to run this by the group.

First, it looks like in one of the previous releases of Virtual Treeview, a dependency on msaaintf.pas was removed.  msaaintf.pas contained a declaration for notifywinevent, which is apparently incorrect in Delphi 7 (see issue 319).  I was seeing access violations in my app on calls to notifywinevent.  This problem was corrected by updating VirtualTrees.pas to include the updated declaration.

This solved the access violations on notifywinevent calls, but screen readers did not read text in rows that had focus.  I noticed that the function WMGetObject in virtualtrees.pas contains a $if directive that requires compiler version 18 in order to make calls to LresultFromObject. 

I think you will have a hard time to convince the current project maintainer (Joachim Marder) to add anything for D7 to the code base. D7 simply too old and keeping compatibility forever is at some point a big hurdle for new development.

Regards,


Joachim Marder

unread,
Jun 9, 2013, 4:15:20 AM6/9/13
to virtual-...@googlegroups.com
Hi Jim

Both problems you describe (incorrect and incomplete API headers) are not related to VirtualTreeView but to Delphi 7 and can be easily solved there by correcting and recompiling the appropriate VCL unit. This a by far better approach for a 10 year old Delphi version than adding workarounds in all affected Delphi components.

Best regards,

Joachim



2013/6/6 Mike Lischke <mike.l...@googlemail.com>

--
You received this message because you are subscribed to the Google Groups "Virtual Treeview" group.
To unsubscribe from this group and stop receiving emails from it, send an email to virtual-treevi...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Charles DeWeese

unread,
Aug 26, 2013, 10:20:45 AM8/26/13
to virtual-...@googlegroups.com
Hello Jim,

You're not alone when it comes to using Delphi 7. I too use it for some applications.

Sadly you are correct and the accessibility support in the virtual treeview is slightly broken for Delphi 7.

Your solution seems acceptable to me, however I think you're missing something with your API declaration. The stdcall;

function LResultFromObject(const riid: TGUID; wParam: WPARAM; punk: IUnknown): LRESULT; stdcall; external 'oleacc.dll' name 'LresultFromObject'; stdcall;


Personally I solved this problem by adding MSAAIntf.pas back to the uses and commenting out the compiler defines in WMGetObject.

Reply all
Reply to author
Forward
0 new messages