Finding Child Windows on an MDI application : Automation API

Finding Child Windows on an MDI application

Class library usage, coding and language questions.

Finding Child Windows on an MDI application

Postby atom » Thu Dec 11, 2008 12:20 pm

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
atom
 
Posts: 339
Joined: Mon Dec 08, 2008 12:14 am
Location: Dublin, Ireland

Postby Support Team » Thu Dec 11, 2008 12:53 pm

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
User avatar
Support Team
Site Admin
 
Posts: 4842
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Postby atom » Thu Dec 11, 2008 12:56 pm

Ahh ok...
But the problem is all our MDI child windows, have non-unique control Id's
atom
 
Posts: 339
Joined: Mon Dec 08, 2008 12:14 am
Location: Dublin, Ireland

Postby Support Team » Thu Dec 11, 2008 1: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 1:27 pm, edited 1 time in total.
User avatar
Support Team
Site Admin
 
Posts: 4842
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Postby atom » Thu Dec 11, 2008 1:04 pm

As i did before?
Havent managaed to do it yet !
atom
 
Posts: 339
Joined: Mon Dec 08, 2008 12:14 am
Location: Dublin, Ireland

Postby Support Team » Thu Dec 11, 2008 1: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
User avatar
Support Team
Site Admin
 
Posts: 4842
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Postby atom » Thu Dec 11, 2008 10:45 pm

aha! thank you, will give it a go
atom
 
Posts: 339
Joined: Mon Dec 08, 2008 12:14 am
Location: Dublin, Ireland

Postby Support Team » Fri Dec 12, 2008 10: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
User avatar
Support Team
Site Admin
 
Posts: 4842
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: Finding Child Windows on an MDI application

Postby srini » Mon Feb 01, 2010 8: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.
srini
 
Posts: 2
Joined: Mon Feb 01, 2010 8:00 pm

Re: Finding Child Windows on an MDI application

Postby Support Team » Tue Feb 02, 2010 12:19 pm

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
User avatar
Support Team
Site Admin
 
Posts: 4842
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria


Return to Automation API

Who is online

Users browsing this forum: No registered users and 0 guests