x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Is it possible to choose the default screen in a multi monitor configuration?

Hi all!

I'm working on a project that requires a fullscreen window to appear in a specific monitor.

My question is: Is it possible (via C++ or Blueprint) to detect how many monitors are being used and set a default monitor in which the program will appear when launched?

An example of what is pretended is, while using a triple-monitor configuration, making the application launch in fullscreen mode in the right monitor.

Thanks in advance for all the help :)

Product Version: UE 4.7
Tags:
more ▼

asked Sep 01 '15 at 11:16 AM in Packaging & Deployment

avatar image

fmartins
36 1 1 5

(comments are locked)
10|2000 characters needed characters left

4 answers: sort voted first

Thanks for all the help. I found a really simple solution for this problem. Here's the source code if anyone comes across the same situation ;)

 // Move window to the corresponding monitor
 if (GEngine && GEngine->GameViewport) {
     
     int MonitorNumber = 1;
     FParse::Value(FCommandLine::Get(), L"monitor=", MonitorNumber);
     
     FDisplayMetrics Display;
     FDisplayMetrics::GetDisplayMetrics(Display);

     int8 MonitorIndex = MonitorNumber - 1;
     int32 CurrentMonitorWidth = Display.MonitorInfo[MonitorIndex].NativeWidth;
     
     float WidthPosition = (MonitorIndex)*Display.PrimaryDisplayWidth - CurrentMonitorWidth;

     float HeightPosition = 0.0f;

     FVector2D WindowPosition = FVector2D(WidthPosition, 0.f);
     GEngine->GameViewport->GetWindow()->MoveWindowTo(WindowPosition);
 }
 
more ▼

answered Sep 07 '15 at 04:44 PM

avatar image

fmartins
36 1 1 5

avatar image CrashAngel Mar 14 '16 at 02:09 AM

As you are creating your game to run on 3 monitors ??? You are using a Multiplayer scheme ???? Or this opening the windows as viewports ???

You could specify the schema that vc this using to open the windows?

avatar image superbjenks Nov 13 '16 at 08:50 PM

Is there any way you can communicate this functionality to a blueprint user? I'm trying my best to understand this, and I get it for the most part - but I've only been able to teach myself blueprint and don't know where to put this code, how to call it, or anything like that when it comes to building my came to run on a non-primary monitor.

avatar image henriquebach May 10 '18 at 01:55 PM

Hello, I'm trying to use this code, but since unreal made some changes in c++, i getting this error when I compile:

error LNK2019: unresolved external symbol "__declspec(dllimport) public: static void __cdecl FDisplayMetrics::GetDisplayMetrics(struct FDisplayMetrics &)" (__imp_?GetDisplayMetrics@FDisplayMetrics@@SAXAEAU1@@Z) referenced in function "protected: virtual void __cdecl UDisplaySettings::BeginPlay(void)" (?Beg inPlay@UDisplaySettings@@MEAAXXZ)

I've already Include the "Engine.h" and "GenericApplication.h", but still no success. Can you help me? I can't find a solution anywhere.

avatar image CyanBalloon Jul 10 '18 at 07:24 PM

I too am stuck with the "unresolved external symbol" error in the 4.19.2 version.

EDIT: I needed to include the following headers:

  • include "GenericApplication.h"

  • include "SWindow.h"

And add the following modules in my project's Build.cs file:

  • ApplicationCore

  • SlateCore

(comments are locked)
10|2000 characters needed characters left

I think all the answers here are incomplete as they assume the following:

  • user has all monitors with the same resolution

  • monitors are aligned from left to right

  • runs only on windows (on linux apparently it does not work properly only in windowed mode)

  • destination monitor also has a native resolution larger or equal to the game resolution

The only information you need is from FMonitorInfo.WorkArea Left/Top.

 FDisplayMetrics Display;
 FDisplayMetrics::GetDisplayMetrics(Display);
     
 // Start on the main display by default
 int32 MonitorNumber = 0;
 FParse::Value(FCommandLine::Get(), TEXT("monitor="), MonitorNumber);
 
 // Get the correct monitor index
 int32 MonitorIndex = INDEX_NONE;
 if (MonitorNumber == 0)
 {
     // Start monitor on the main screen
     for (int32 Index = 0; Index < DisplayMetrics.MonitorInfo.Num(); Index++)
     {
         if (DisplayMetrics.MonitorInfo[Index].bIsPrimary)
         {
             MonitorIndex = Index;
             break;
         }
     }
 }
 else
 {
     // Normalize
     MonitorIndex = MonitorNumber - 1;
 }
  
 if (DisplayMetrics.MonitorInfo.IsValidIndex(MonitorIndex))
 {
     const FMonitorInfo Monitor = DisplayMetrics.MonitorInfo[MonitorIndex];
     // check if UserSettings.ResolutionSizeX > Monitor.NativeWidth || UserSettings.ResolutionSizeY > Monitor.NativeHeight
     // if true then change your game resolution to Monitor.NativeWidth, Monitor.NativeHeight
 
     const int32 WindowPosX = Monitor.WorkArea.Left;
     const int32 WindowPosY = Monitor.WorkArea.Top;
     const FVector2D Position(static_cast<float>(WindowPosX), static_cast<float>(WindowPosY));
 
     if (GEngine && GEngine->GameViewport)
     {
         TSharedPtr<SWindow> Window = GEngine->GameViewport->GetWindow();

         // Hack for linux
 #if PLATFORM_LINUX
        const EWindowMode::Type CurrentWindowMode = Window->GetWindowMode();
        Window->SetWindowMode(EWindowMode::Windowed);
 #endif

         Window->MoveWindowTo(Position);

 #if PLATFORM_LINUX
         // Set back to original
         Window->SetWindowMode(CurrentWindowMode);
 #endif
     }
 }

more ▼

answered Jul 06 '18 at 05:08 PM

avatar image

leyyin
21 4 5

avatar image GranolaStudios Feb 22 '19 at 02:43 PM

Perfect, thank you. This is the complete answer!

(comments are locked)
10|2000 characters needed characters left

In C++ you got this:

https://docs.unrealengine.com/latest/INT/API/Runtime/Core/GenericPlatform/FDisplayMetrics/index.html

First you call this to get the metrics:

 FDisplayMetrics Display;
 FDisplayMetrics::GetDisplayMetrics(Display);

And then you check how many moniters there is by checking MonitorInfo array size with Display.MonitorInfo.Num()

more ▼

answered Sep 01 '15 at 02:04 PM

avatar image

Shadowriver
34.7k 918 166 1095

(comments are locked)
10|2000 characters needed characters left

As far as I can tell Unreal does not support this natively, but it would be platform specific.

On windows you should be able to use the info here:

https://www.microsoft.com/msj/0697/monitor/monitor.aspx

Essentially what you do is you enumerate all your monitors, find the one you want, and then move your application to there and maximize it.

edit:

Looking in WindowsWindow.cpp, you probably want to write a function very similar to GetFullScreenInfo that just enumerates the windows instead of using a rectangle and then gets the corresponding data from it, then use MoveWindowTo to move the window to there and MAximize to biggify it.

more ▼

answered Sep 01 '15 at 02:04 PM

avatar image

mrooney
693 40 31 123

avatar image Shadowriver Sep 01 '15 at 02:06 PM

UE4 got huge set of platfrom specific function wrappers, specially made so it's easy to make your game portable (well technily it was made to make engine portable :p):

https://docs.unrealengine.com/latest/INT/API/Runtime/Core/GenericPlatform/index.html

avatar image mrooney Sep 01 '15 at 02:20 PM

I was looking for something like that, but couldn't figure out where EnumDisplayDevices was hooked up to something generic. The spot in your answer looks like that spot. :p

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question