Finding Child Windows on an MDI application

Class library usage, coding and language questions.
atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

Finding Child Windows on an MDI application

Post by atom » Thu Dec 11, 2008 11:20 am

Hiya

Im a bit confused as to how you can find child windows of an MDI application.
It seems there is no way to search the child windows of a window and return a Form object... you can only return a Control/Element

Eg.
I want to do the following

- Find the main application window
- Find the MDI Client window
- Find all child windows of the MDI Client

and have each of them as a Form object - how is that possible?
there seems to be no method to search a Form for a child Form, and return a Form object.

Or does Ranorex only consider top level windows as Form objects?

Thanks

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Thu Dec 11, 2008 11:53 am

You can construct a Form instance from any control:

Code: Select all

Control mdiControl = form.FindControlId(12345);
Form mdiForm = new Form(mdiControl.Handle);
Its methods and properties will only work, however, if the control is really a form.

Regards,
Alex
Ranorex Support Team

atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

Post by atom » Thu Dec 11, 2008 11:56 am

Ahh ok...
But the problem is all our MDI child windows, have non-unique control Id's

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Thu Dec 11, 2008 12:00 pm

Just find the MDI windows as you did before (I used the FindControlId method as a sample) and construct the Form instances from the control instances.

Regards,
Alex
Ranorex Support Team
Last edited by Support Team on Thu Dec 11, 2008 12:27 pm, edited 1 time in total.

atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

Post by atom » Thu Dec 11, 2008 12:04 pm

As i did before?
Havent managaed to do it yet !

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Thu Dec 11, 2008 12:37 pm

You did manage to find your MDI client windows as Control instances, didn't you? If not, try searching for them using the Control.FindClassName method and specify "MDIClient" as class name.

When you got your MDI client window as a Control instance, you can construct a Form instance from its Control.Handle. You can get its child controls by accessing the Children property. The Control.Text property correpsonds to the caption of the MDI child window.

Regards,
Alex
Ranorex Support Team

atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

Post by atom » Thu Dec 11, 2008 9:45 pm

aha! thank you, will give it a go

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Fri Dec 12, 2008 9:44 am

You can also use the Control.FindChildText method that searches for a child window with a specific text (i.e. the caption of your MDI child window).

Regards,
Alex
Ranorex Support Team

srini
Posts: 2
Joined: Mon Feb 01, 2010 7:00 pm

Re: Finding Child Windows on an MDI application

Post by srini » Mon Feb 01, 2010 7:30 pm

Hi Alex,

I tried using FindChild and FindDescendant to find MDI child windows but no luck. If you get a chance could you please send me some sample code on code on finding of MDI child and MDI controls.

That would be very helpful for me if you sending the code ASAP.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Finding Child Windows on an MDI application

Post by Support Team » Tue Feb 02, 2010 11:19 am

srini wrote:That would be very helpful for me if you sending the code ASAP.
We can't provide you with any code, because we don't know how your application looks like. Please, post a Ranorex snapshot (see http://www.ranorex.com/support/user-gui ... html#c2072) of your application!

Basically, you should analyze your application using Ranorex Spy (see http://www.ranorex.com/support/user-gui ... x-spy.html) and check whether Ranorex Spy recognizes the child windows in your MDI application. Then you can use the generated RanoreXPath to find the elements corresponding to your controls.
Please note that although "Tracking" sometimes does not work correctly, Ranorex might still be able to identify the controls. Try to enable "Highlight Elements" from the toolbar and navigate in the element tree in order to find the child controls!

Regards,
Alex
Ranorex Support Team
.
Image