Resizing application window

Ask general questions here.
Mirage
Posts: 11
Joined: Mon May 04, 2009 11:04 am

Resizing application window

Post by Mirage » Mon Jun 15, 2009 5:46 pm

I didn't find a way to resize an application window in Ranorex 2.1. I found a way to move a window (MoveTo), but there's no way to resize it.

Class Element contains Size and ScreenRectangle, but those cannot be set. Nor there is any action or attribute to modify the size.

Thanks for any suggestions.

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Post by Ciege » Mon Jun 15, 2009 6:21 pm

Do you need more than the .Maximize, .Minimize & .Restore methods?

Maybe you can try getting the location & size of the form then doing a click down, mouse move & click up to stretch the form yourself?
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

Mirage
Posts: 11
Joined: Mon May 04, 2009 11:04 am

Re: Resizing application window

Post by Mirage » Tue Jun 16, 2009 9:41 am

I need to be able to resize the window so that components within it are resized too (to a specific size so I can take and compare a screenshot of them).

Your suggestion is an ugly hack which I'd like to avoid.

Thanks

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

Re: Resizing application window

Post by Support Team » Tue Jun 16, 2009 3:03 pm

If your window is a .NET Windows Forms control, you can in fact set its Size and Location using the Control.SetPropertyValue method:
Ranorex.Unknown myWindow = "...";
Ranorex.Control myControl = myWindow.As<Control>();
myControl.SetPropertyValue("Size", new Size(300, 200));
However, in general I recommend the method Ciege mentioned since it is more similar to the actions a human user would perform. There are methods to set the size/location of windows directly, e.g. via the Windows API, but these methods bypass the standard user actions and are not guaranteed to have the same effect (e.g. if you'd set the size of a .NET Windows Forms Form through Windows API messages, the SizeChanged event in the form might not be raised resulting in undefined behaviour of your application).

Regards,
Alex
Ranorex Support Team
.
Image