Skip to content

Commit

Permalink
Hotfix, keep game in bounds, cleaned up code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Codeusa committed Jan 13, 2014
1 parent fcf3190 commit 70aabbe
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 37 deletions.
75 changes: 38 additions & 37 deletions Borderless.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,19 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace BorderlessGaming
{

public partial class Borderless : Form
{
#region SHIT CODE

#region Delegates



#endregion

public static readonly Int32
Expand Down Expand Up @@ -73,20 +68,27 @@ public static readonly Int32
private string _selectedFavoriteProcess;

/// <summary>
/// The MoveWindow function changes the position and dimensions of the specified window. For a top-level window, the position and dimensions are relative to the upper-left corner of the screen. For a child window, they are relative to the upper-left corner of the parent window's client area.
/// </summary>
/// <param name="hWnd">Handle to the window.</param>
/// <param name="X">Specifies the new position of the left side of the window.</param>
/// <param name="Y">Specifies the new position of the top of the window.</param>
/// <param name="nWidth">Specifies the new width of the window.</param>
/// <param name="nHeight">Specifies the new height of the window.</param>
/// <param name="bRepaint">Specifies whether the window is to be repainted. If this parameter is TRUE, the window receives a message. If the parameter is FALSE, no repainting of any kind occurs. This applies to the client area, the nonclient area (including the title bar and scroll bars), and any part of the parent window uncovered as a result of moving a child window.</param>
/// <returns>If the function succeeds, the return value is nonzero.
/// <para>If the function fails, the return value is zero. To get extended error information, call GetLastError.</para></returns>

/// The MoveWindow function changes the position and dimensions of the specified window. For a top-level window, the
/// position and dimensions are relative to the upper-left corner of the screen. For a child window, they are relative
/// to the upper-left corner of the parent window's client area.
/// </summary>
/// <param name="hWnd">Handle to the window.</param>
/// <param name="X">Specifies the new position of the left side of the window.</param>
/// <param name="Y">Specifies the new position of the top of the window.</param>
/// <param name="nWidth">Specifies the new width of the window.</param>
/// <param name="nHeight">Specifies the new height of the window.</param>
/// <param name="bRepaint">
/// Specifies whether the window is to be repainted. If this parameter is TRUE, the window receives
/// a message. If the parameter is FALSE, no repainting of any kind occurs. This applies to the client area, the
/// nonclient area (including the title bar and scroll bars), and any part of the parent window uncovered as a result
/// of moving a child window.
/// </param>
/// <returns>
/// If the function succeeds, the return value is nonzero.
/// <para>If the function fails, the return value is zero. To get extended error information, call GetLastError.</para>
/// </returns>

#endregion

public Borderless()
{
InitializeComponent();
Expand Down Expand Up @@ -224,21 +226,22 @@ private void RemoveBorder(String procName) //actually make it frameless
Native.SetWindowLong(pFoundWindow, GWL_STYLE,
(style &
~(WindowStyleFlags.ExtendedDlgmodalframe
| WindowStyleFlags.Caption
| WindowStyleFlags.ThickFrame
| WindowStyleFlags.Minimize
| WindowStyleFlags.Maximize
| WindowStyleFlags.SystemMenu
| WindowStyleFlags.MaximizeBox
| WindowStyleFlags.MinimizeBox
| WindowStyleFlags.Border
| WindowStyleFlags.ExtendedComposited)));
| WindowStyleFlags.Caption
| WindowStyleFlags.ThickFrame
| WindowStyleFlags.Minimize
| WindowStyleFlags.Maximize
| WindowStyleFlags.SystemMenu
| WindowStyleFlags.MaximizeBox
| WindowStyleFlags.MinimizeBox
| WindowStyleFlags.Border
| WindowStyleFlags.ExtendedComposited)));


var bounds = Screen.PrimaryScreen.Bounds;
Native.SetWindowPos(pFoundWindow, 0, 0, 0, bounds.Width, bounds.Height, SWP_NOZORDER | SWP_SHOWWINDOW); //no more outside window
// CheckNativeResult(() => Native.MoveWindow(pFoundWindow, 0, 0, bounds.Width, bounds.Height, true));
//resets window to main monitor
Native.SetWindowPos(pFoundWindow, 0, 0, 0, bounds.Width, bounds.Height, SWP_NOZORDER | SWP_SHOWWINDOW);
//no more outside window
// CheckNativeResult(() => Native.MoveWindow(pFoundWindow, 0, 0, bounds.Width, bounds.Height, true));
//resets window to main monito
_gameFound = true;
}

Expand Down Expand Up @@ -315,7 +318,6 @@ private void BugReportClick(object sender, EventArgs e)
GotoSite("https://github.com/Codeusa/Borderless-Gaming/issues");
}



private void RemoveFavoriteButton(object sender, EventArgs e)
{
Expand All @@ -342,15 +344,16 @@ private void SupportButtonClick(object sender, EventArgs e)
{
GotoSite("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=TWHNPSC7HRNR2");
}

protected override void OnResize(EventArgs e)
{
base.OnResize(e);
base.OnResize(e);
//determine whether the cursor is in the taskbar because Microsoft
var cursorNotInBar = Screen.GetWorkingArea(this).Contains(Cursor.Position);
if (WindowState != FormWindowState.Minimized || !cursorNotInBar) return;
ShowInTaskbar = false;
notifyIcon.Visible = true;
// notifyIcon.Icon = SystemIcons.Application;
// notifyIcon.Icon = SystemIcons.Application;
notifyIcon.BalloonTipText = "Borderless Gaming Minimized";
notifyIcon.ShowBalloonTip(2000);
Hide();
Expand All @@ -360,15 +363,13 @@ private void TrayIconOpen(object sender, EventArgs e)

{
Show();
WindowState = FormWindowState.Normal;
ShowInTaskbar = true;

WindowState = FormWindowState.Normal;
ShowInTaskbar = true;
}

private void TrayIconExit(object sender, EventArgs e)
{
Environment.Exit(0);
Environment.Exit(0);
}

}
}
2 changes: 2 additions & 0 deletions NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ namespace BorderlessGaming
[Flags]
public enum WindowStyleFlags : uint
{


Overlapped = 0x00000000,
Popup = 0x80000000,
Child = 0x40000000,
Expand Down

0 comments on commit 70aabbe

Please sign in to comment.