views:

302

answers:

1

Our application has many controls that are created dynamically. For example, a navigation pane contains groups of links that change as the user navigates through the app. The first time I use AccExplorer to select these links, it finds them perfectly. However, after I navigate to another page, AccExplorer can't see the links in the updated navigation pane. In fact, the old link controls still appear in the AccExplorer tree hierarchy and as I click on them AccExplorer highlights areas of the desktop that are outside the bounds of our application's actual window.

The controls have changed, but AccExplorer doesn't recognize them. It still thinks the hierarchy is the same.

What I find strange is that closing AccExplorer and then opening a new instance of AccExplorer results in the same results. When I select the new navigation control with AccExplorer, it doesn't see the new links. It recreates the old hierarchy with the old links. The only way to see the new links is if I close our application, reopen our application, manually navigate to the new page, then select the controls with AccExplorer.

The navigation control is a DevExpress control. OS is WinXP. AccExplorer 2.0. I'd prefer to use UIAutomation, but not all DevExpress controls support UIAutomation. We're trying to use MSAA to fill in those gaps.

A: 

To follow up...

With UISpy I'm able to find a control called LeftNavExplorerBarGroups that AccExplorer cannot see. I'm able to use UIAutomation to get the window handle of the control then use the handle to find the IAccessible object with MSAALayer. The fact that AccExplorer can't see that control and that the accName is null made it very difficult to discover how to find the controls I needed. (Note: MSAA comes from Arshad - http://www.codeproject.com/KB/winsdk/MSAA%5FUI%5FAutomation.aspx)

AutomationElement a, b;
Process p;
Process[] existingProcesses;
IAccessible c;

existingProcesses = Process.GetProcessesByName("OurApp");
if (existingProcesses.Length > 0) {
  p = existingProcesses[0];
  a = AutomationElement.FromHandle(p.MainWindowHandle);
  b = a.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, "LeftNavExplorerBarGroups"));
  c = MSAA.GetAccessibleObjectFromHandle(new IntPtr(b.Current.NativeWindowHandle));
}