About/Contact

Steve Trefethen

Steve Trefethen is a Director of Engineering at Reply. Contact me

View my LinkedIn profile


Powered by discountASP.NET
referal ID: sdtref
Why recommend discountASP.NET?
$720 in referrals so far!


Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar

Disclaimer

The posts on this weblog are provided AS IS with no warranties, and confer no rights. The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.



Using the MSAA IAccessible interface within a Delphi Application

November 16 2004 8:58PM

I've been investigating Microsoft's IAccessible interface recently and thought I would begin a series of posts related to using IAccessible in a Delphi application from an MSAA server perspective.  From the MSDN:

”The IAccessible interface is the heart of Microsoft Active Accessibility. Applications implement this Component Object Model (COM) interface to represent their custom user interface elements, which can include their client area as accessible objects, if necessary.”

In order to start using IAccessible the first step is to import the oleacc.dll type library which provides us with the necessary interface declarations.  Having dug into this interface a bit I can save you a little time and simply give you the TLIBIMP command line necessary to properly import this type library.

tlibimp -Hs- -Hr- -Ftoleacc -Ps- -O- %systemroot%\SYSTEM32\OLEACC.DLL

If you'd like to import this type library from within the IDE make sure to set Delphi's type library importer so that it does not map the interface declarations as safecall since some of the interfaces require a specific HRESULT.  To do that select Tools|Options and change the Type Library option for “Safecall function mapping” to “Do not map”.

The second step is to check the declaration of NotifyWinEvent API located in Windows.pas to make sure it's correct.  I found that it wasn't declared as stdcall which resulted in an AV whenever I called it.  If you ever find yourself getting an AV when you call a Windows API function double check the declared calling convention of the function import before going any further.

Here is the corrected declaration:

procedure NotifyWinEvent(event: DWORD; hwnd: HWND; idObject, idChild: Longint); stdcall;

Ok, now that we have those two steps out of the way we've opened the door to enabling our Delphi applications through MSAA.  Since this is a fairly large topic I'm going try and tackle it in small pieces so stay tuned for the next step.  In a future post I'll begin to discuss actually putting this interface to use.

[UPDATED: Dec 2, 2004 2:14pm PST] Chris Hesik of the Delphi development team has written this article where he discusses, among other things, one method for debugging calling convention declaration errors.

FacebookDel.icio.usDigg It!

Comments (4) -

3/15/2007 1:33:00 PM #

Did you ever write anymore articles.  I'm using Delphi 6 and have an ActiveX control that runs in IE.  I wanted to investigate implementing accessibility stuff, but I haven't seen any examples in the internet.

Mark D

3/15/2007 5:39:36 PM #

Hi Mark,
Unfortunately, I never got back to this partly because the example I was going to talk about was for a MainMenu system (TActionMainMenuBar) but it didn't really seem all that applicable since the vast majority of people don't develop main menu controls. At present, the TActionMainMenuBar does implement the IAccessible interface so there is an example of how this interface can be used included with the VCL. The code is included with Delphi 2005, BDS 2006 and the Turbo products.

That said, this is a topic I would like to get back to though it looks like Microsoft may have changes strategies again regarding adding Accessibility support to Windows applications so I need to do some more investigation.

Steve Trefethen

7/8/2008 11:40:05 PM #

Hey,

Could you tell me how to implement the IAccessible interface within a Flex application so as to expose the Flex objects to TestComplete.

thanks,
Abhe

Abhe

7/9/2008 2:57:48 AM #

Hi Abhe,
  Unfortunately, I'm not familiar with Flex so I'm afraid I can't offer much on the subject.

Steve Trefethen

Add comment




  Country flag
biuquote
  • Comment
  • Preview
Loading