How to set main window dimensions?

This seems like it should be trivial, but for the life of me I cannot figure out how to change the size the application starts. I have tried editting and loading the settings.xml, setting the Height on the application.mainwindow and various other places.

This is for my terrain server that just wants a small tool sized window, but defaults to a huge tall window. It is based on the indy socket server demo.

I’m probably wrong, but the GameInitialize.pas has (on the very bottom) hardcoded portrait size, in a place that I wouldn’t even look. Sorry in advance if my answer is too obvious, I just share my own short experience with CGE :slight_smile:

  { Special code in client / server examples:
    Portrait-like aspect ratio, similar to mobile portrait mode. }
  Window.Width := Application.ScreenWidth div 3;
  Window.Height := Application.ScreenHeight * 3 div 4;

2 Likes

That is totally the correct answer. I was pulling all my hair out. Fortunately I don’t have that much. Thanks!

Indeed. The full answer is that you can set Window.Width / Window.Height to anything (hardcoded or based on Application.ScreenWidth / ScreenHeight).

The caveat is that you have to do this before the window is opened, because later changes to Window.Width / Height are ignored. When following our standard program layout, the window gets opened when the main program calls Application.MainWindow.OpenAndRun, so you need to change the Window.Width / Height earlier, like in initialization of some unit.

1 Like