windowfromaccessibleobject returns zero
Hi Everybody,
Please help.
MSAA API windowfromaccessibleobject returns zero. I have no idea why it does this, because I know there is handle to that control(Its checked with various other methods).
[DllImport("oleacc.dll")]
public static extern uint WindowFromAccessibleObject(IAccessible pacc, ref IntPtr phwnd);
Please help.
Regards,
Kavya
[376 byte] By [
ASKavya] at [2008-1-10]
I use following signature and everything works fine:
public static extern int WindowFromAccessibleObject(IAccessible pacc, out IntPtr hwnd);
What is the error code returned from the function if there is one?
HI Marco,
Sorry. I could not check the response as I was out of station
Thanks you. I shall try it.
But I feel I have tried this earlier.
for the previous signature, no error code. Handle use to be zero
HI Marco,
I did check. It doesn't give me any error code. it actually passes the try block.
but handle is zero. 
try {
NativeMethods.WindowFromAccessibleObject(accObj, out Handle);
} catch (Exception e) {
Console.WriteLine(e.Message);
}
HI Marco,
I got actually busy with something. hence couldn't continue!! 
Hope to seek your help still
int res= NativeMethods.WindowFromAccessibleObject(accObj, out Handle);
Win32Exception win32 = new Win32Exception(res);
Console.WriteLine(win32.InnerException);
Console.WriteLine(win32.Message);
Console.WriteLine(win32.Source);
I get this error ."An outgoing call cannot be made since the application is dispatching an input-synchronous call" for the above code.
Please help me 
Hi,
I also came across couple of links which says, we can call this in timer event to make it async. Since it is in single thread for me.
Few of the below links
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_20152915.html
http://mikedimmick.blogspot.com/2004/02/on-com-pumping-and-clr.html
But, Mine is not a winform app to put timer, So any better suggestion?
Please ehlep
I had the same problem Here is what I did:
(Windows.Control is my own class not a System.Windows.Forms.Control)
''' <summary>
''' The parent control accociated with the accessibility element
'''
</summary> '''
<remarks></remarks> Private
m_Control As
Windows.Control ''' <summary>
''' The control that contains this Active Accessibility element
'''
</summary> '''
<value></value> '''
<returns></returns> '''
<remarks></remarks> <TypeConverter(
GetType
(ExpandableObjectConverter))> _Public
ReadOnly
Property
Control() As
Windows.ControlGet
If
m_Control Is
Nothing
Then
Using
r As
New
Threading.AutoResetEvent(False
)Dim
t As
New
Threading.Thread(AddressOf
GetWindow)t.Start(r)
r.WaitOne()
End
Using
End
If
Return
m_ControlEnd
Get
End
Property
''' <summary>
''' Get the window from the accessible object.
'''
</summary> '''
<remarks></remarks> Private
Sub
GetWindow(ByVal
resetevent As
Object
)Dim
hWnd As
IntPtrWindowFromAccessibleObject(m_Element, hWnd)
m_Control = Windows.Control.Create(hWnd,
Nothing
, m_Application, 0)Dim
r As
Threading.AutoResetEvent = TryCast
(resetevent, Threading.AutoResetEvent)r.Set()
End
Sub