How to set window position and border

Changing game window position through GameUserSettings->SetWindowPosition didn’t work me either. Fortunately, I’ve found solution. (Thanks Epic for access to your source code!! <3)

So, here’s what I’ve done:

Uncommented this line in file GAMENAME.Build.cs

PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });

And then, I used, this (you can use this basically everywhere):

if (GEngine && GEngine->GameViewport)
{
    FVector2D WindowPosition = FVector2D(0.f, 0.f);
    GEngine->GameViewport->GetWindow()->MoveWindowTo(WindowPosition);
}

Ofc, you’ll have to calculate WindowPosition on your own, but I’m sure you’ll be able to do so easily. :stuck_out_tongue:

Tested on UE4.7.3 DebugGame Editor build.

Edit:

I just tested if it’s possible to set game window between 2 monitors and it works properly.

So, in scenario where you’d have 4 screens and each of them would be full HD and your primary screen would be 1st from the right you’d have to use WindowPosition with X value == (-1) * 3 * 1920. and Y == 0

Hope it helps. :stuck_out_tongue:

1 Like