How to properly maximize a window?

I’m sure this is a silly question for you veterans but, how do you properly maximize a window on application startup? So far, I’ve added code like this to my app open() event:

MainWindow.Maximize

This works great on Mac OSX, but on Windows 7 I’m treated to a nice animation as all my controls are re-positioned and moved around. In other frameworks I simply set the initial state of the window to maximized but I’m not finding a Xojo equivalent.

Do it in the Open Event of the Window?

Thanks for the reply Jym, but I get the same result there as well.

I’d be interested to know, too. Even the Xojo IDE doesn’t re-open to it’s maximized state - the window does fill the screen, but you have to click the Windows maximize button to get it to true full screen. Tried on Windows 7 64bit.

I am using the w.maximize … did you lock the controls as the window resizes when you maximize, so they not move around ?

I did finally manage to come up with a solution so for the benefit of those with the same issue, I’ll post my workaround here. It’s somewhat kludgy but seems to work on Windows 7 64 and Mac OS 10.8:

  1. Set the full screen property for the window in question to “True”
  2. In the window open event, add the following code:

me.FullScreen = false me.Maximize

In my testing, the window opens with all controls positioned/sized properly.

Interesting possibility although I didnt try it. I did try to loop through all controls setting the visible property to false then to true in the open event without luck.

I want my main screen to be NOT maximized when app opens, but if they maximize it then I want to store that as a preference and keep it maximized. However, if I close a file for example, my window keeps going back to the small version even though I am calling Me.Maximize before the end of the file close.

Is this problem something to do with FullScreen? What is the difference between FullScreen and Maximize?

Xojo is very “unfriendly” when it’s about to displaying controls, centering, wrapping, stretching, autosizing etc etc
you have to find “workarounds” and the results are umpredictable

Only if you do not know what you are doing :wink:

I just went through this, and for the sake of others who may follow in our footsteps, the easiest and best solution these days is to use the MonkeyBreadSoftware IsZoomedMBS. It works on both Mac (Cocoa and later) and Windows.

To maximize a window:

wnd.IsZoomedMBS = True

To get the maximized status of a window:

dim IsMax as boolean = wnd.IsZoomedMBS