Problem with TreeScope in Automation.AddAutomationEventHandler

Hi!
I would like to handle automation events, such as InvokePattern.InvokedEvent. I use the Automation.AddAutomationEventHandler method with different tree scopes (always with the same handler function called MyAutomationEventHandler).
Automation.AddAutomationEventHandler(event, element, scope, new AutomationEventHandler(MyAutomationEventHandler));
The arguments are the AutomationEvent, the AutomationElement, the TreeScope, and the AutoamtionEventHandler delegate.
My problem is the following:
- if I use TreeScope.Element: the handler works perfectly
- if I use TreeScope.Children: nothing happens, the handler method is never called for any children
- if I use TreeScope.Subtree: nothing happens, the handler method is never called for any element of the subtree. But if I add another handler at this time for an element (that is in the former subtree) with TreeScope.Element, then the handler method will be called twice each time when the event occurs for the specific element.
I don't know, what the problem is.
Mark

[1078 byte] By [MarkAsztalos] at [2008-1-29]
# 1
I have forgotten to mention, that the program under test was not a WPF application. I created a simple WPF application and the scopes work perfectly, it was my fault that I tested simple win32 applications.
I met some other problems when using UIA on win32 applications, so I think the proxies that let the legacy controls connect to the UIA framework do not work well, or some features are missing from them.

My question is: is it true, that the aim is that we could use the UIA framework on legacy controls? Probably, in the final version of the sdk it will work?
Thanks, Mark

MarkAsztalos at 2007-9-10 > top of Msdn Tech,Software Development for Windows Vista,Microsoft UI Automation...

Software Development for Windows Vista

Site Classified