Page 1 of 1

Resizing application window

Posted: Mon Jun 15, 2009 5:46 pm
by Mirage
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.

Posted: Mon Jun 15, 2009 6:21 pm
by Ciege
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?

Re: Resizing application window

Posted: Tue Jun 16, 2009 9:41 am
by Mirage
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

Re: Resizing application window

Posted: Tue Jun 16, 2009 3:03 pm
by Support Team
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