Click to See Complete Forum and Search --> : WindowsAccessBridge in .Net (Java Accessibility)


ganeshvijay
November 30th, 2004, 11:15 PM
Hi!

I want to use an API "GetAccessibleContextInfo" in my C# code to collect control information from a java window. This API call works fine in Delphi but not in C#. The API reads like this:

BOOL GetAccessibleContextInfo(long vmID, AccessibleContext ac, AccessibleContextInfo *info);
where;

vmID = output from the API [BOOL GetAccessibleContextFromHWND(HWND target, long *vmID, AccessibleContext *ac)]. //This works fine.
ac = output from the above API. //This also works fine.

*info = this makes the problem. AccessibleContextInfo is a structure.

But how can I replace the above pointer to a corresponding C# code?
Tried with IntPtr, Void*, etc.. but no use...
How can I point to the structure defined or how can I Marshal the pointer to a structure?

Any idea?

regrds
Ganesh.

Konstantin Adarchenko
February 22nd, 2005, 03:40 AM
ok first of AccessibleContextInfo is a struct that you have to marshal in C# in order to allow the dll to fill it, so
here is the struct

[StructLayout(LayoutKind.Sequential)]
public struct AccessibleContextInfo
{
string name; // the AccessibleName of the object
string description; // the AccessibleDescription of the object

string role; // localized AccesibleRole string
string states; // localized AccesibleStateSet string
// (comma separated)

long indexInParent; // index of object in parent
long childrenCount; // # of children, if any
long x; // screen coords in pixels
long y; // "
long width; // pixel width of object
long height; // pixel height of object

bool accessibleComponent; // flags for various additional
bool accessibleAction; // Java Accessibility interfaces
bool accessibleSelection; // FALSE if this object doesn't
bool accessibleText; // implement the additional interface
bool accessibleValue; // in question
};

now, instead of sending a general pointer or an object , send a ref to a variable of the struct