From 4bcd5facd3677b0f2bf2cd59741d55c870ac32a8 Mon Sep 17 00:00:00 2001 From: Stack-of-Pancakes Date: Mon, 13 Jan 2014 14:20:52 -0500 Subject: [PATCH] Multi monitor support Was testing this and it took my game from my larger monitor that I play on and moved it to my primary monitor. This change checks the monitor that the game is currently running on and fullscreens it there instead of defaulting to 0,0 which is top left of the system's primary monitor. --- Borderless.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Borderless.cs b/Borderless.cs index d720938..257eec6 100644 --- a/Borderless.cs +++ b/Borderless.cs @@ -185,14 +185,20 @@ private void RemoveBorder(String procName) //actually make it frameless | WindowStyleFlags.ExtendedComposited))); - var bounds = Screen.PrimaryScreen.Bounds; + //Get the screen bounds from the screen the window is currently active on. + //If on multiple screens it will grab bounds from the screen it is most on. + //If not on any screen it grabs bounds from the screen closest + var bounds = Screen.FromHandle(pFoundWindow).Bounds; + if (!_borderlessWindows.Contains(pFoundWindow.ToInt32().ToString())) { - Native.SetWindowPos(pFoundWindow, 0, 0, 0, bounds.Width, bounds.Height, - SWP_NOZORDER | SWP_SHOWWINDOW); + //Using bounds.X and bounds.Y instead of 0, 0 so it will orient the window + //on the screen it is currently occupying instead of using the primary screen + Native.SetWindowPos(pFoundWindow, 0, bounds.X, bounds.Y, bounds.Width, bounds.Height, SWP_NOZORDER | SWP_SHOWWINDOW); _borderlessWindows.Add(pFoundWindow.ToInt32().ToString()); } //today I learn the definition of a hot fix - + + //no more outside window // CheckNativeResult(() => Native.MoveWindow(pFoundWindow, 0, 0, bounds.Width, bounds.Height, true)); //resets window to main monito @@ -326,4 +332,4 @@ private void TrayIconExit(object sender, EventArgs e) Environment.Exit(0); } } -} \ No newline at end of file +}