How do I properly move my Game Window?

Our application requires that the game window opens on a particular monitor indicated by a command line argument.

Right now, I created a UCustomGameClass that derives from UGameEngine and registered it for use in the DefaultEngine.ini file using
[/Script/Engine.Engine]
GameEngine=/Script/Unreal3DViewer.CustomGameEngine

In that file I override Init(IEngineLoop* InEngineLoop), call Super::Init() and then
GameViewport->GetWindow()->ReshapeWindow() to the coordinates I want to use.

This mostly works, the application opens on the main screen and is immediately moved to the desired monitor.
Ideally we would be able to open it directly on the target monitor but, from what I can gather this would require making changes to the engine itself which are currently trying to avoid.

The one issue we are having with this is when alternate monitors don’t have the same resolution as the main monitor.

At some point during initialization, after UEngineInit, FSceneViewport::ResizeFrame is called which changes the window’s size based on the main monitor size.
I can’t find a way around this.

Ideally, is there some way to get a window to open in the desired location right off the bat?

If not, where could I resize my window and not have other engine code further change it’s size? (Preferably not in the game code. We could have it in the controller BeginPlay for example but that would be a poor solution).

Hi @straypet , and anyone else bumping into this problem. I might have a solution, check the thread here: How to select on which monitor to display the game ? - #12 by alexpanter

1 Like