Cannot identify controls inside HwndHost window

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
sdstryker
Posts: 1
Joined: Tue Feb 20, 2018 9:37 pm

Cannot identify controls inside HwndHost window

Post by sdstryker » Wed Feb 21, 2018 4:45 pm

We have a legacy WinForm app that is being hosted inside a newer WPF app. The WinForm app is run as a separate process, and it's main window is attached as a child to a WPF HwndHost control. Ranorex cannot identify the WinForm window or any of its child controls. I realize this is not a typical design but would appreciate any suggestions.

I reproduced the issue with a small test application. In the attached screenshot the gray window inside the MainWindow is the hosted WinForm window. The screenshot was taken while hovering over the text box control with Ranorex Spy. As you can see, the Spy is identifying the WPF window but nothing inside. I have also attached sample code for analysis.

OS: Windows 7 Enterprise, Service Pack 1
HW: 64-Bit Xeon Processor with 16GB Ram
Attachments
HwndHostTest.zip
Sample code and screenshot
(295.29 KiB) Downloaded 20 times

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Cannot identify controls inside HwndHost window

Post by krstcs » Wed Feb 21, 2018 9:40 pm

In this situation, my understanding (I could be completely wrong, and hope I am!! :D ) of how the sub-process boxing works is that the window is treated as a bitmap that is constantly updated by the back-end WinForms process and mouse and keyboard input are passed through based on location and currently selected input box, etc.

So, the problem with this is that it works pretty much the same way that RDP does (there are a number of threads about RDP here) and Ranorex cannot see any elements inside that window, it's just a bitmap/image.

The only way to get around this, while leaving the system as is, is to use image-based recording, which is not recommended unless absolutely necessary because it is very brittle.

The other option would be to run the WinForms process on it's own and test it separately using Ranorex, if that's possible.
Shortcuts usually aren't...