From 195b2b5edf2490df422d1aa6ae112518f6c17385 Mon Sep 17 00:00:00 2001 From: Afevis Date: Mon, 3 Mar 2025 09:52:53 -0700 Subject: [PATCH 1/4] Adds a "-noborder" launch argument for borderless windowed mode --- Generals/Code/Main/WinMain.cpp | 19 ++++++++++++++++++- GeneralsMD/Code/Main/WinMain.cpp | 20 +++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/Generals/Code/Main/WinMain.cpp b/Generals/Code/Main/WinMain.cpp index 77323a00c7..effcc59245 100644 --- a/Generals/Code/Main/WinMain.cpp +++ b/Generals/Code/Main/WinMain.cpp @@ -75,6 +75,12 @@ HINSTANCE ApplicationHInstance = NULL; ///< our application instance HWND ApplicationHWnd = NULL; ///< our application window handle Bool ApplicationIsWindowed = false; + + // =================== Community Fix Start ================= + // Borderless Support - PR #327 // +Bool ApplicationIsBorderless = false; + // =================== Community Fix End ================= + Win32Mouse *TheWin32Mouse= NULL; ///< for the WndProc() only DWORD TheMessageTime = 0; ///< For getting the time that a message was posted from Windows. @@ -674,7 +680,12 @@ static Bool initializeAppWindows( HINSTANCE hInstance, Int nCmdShow, Bool runWin // Create our main window windowStyle = WS_POPUP|WS_VISIBLE; if (runWindowed) - windowStyle |= WS_DLGFRAME | WS_CAPTION | WS_SYSMENU; + // =================== Community Fix Start ================= + // Borderless Support - PR #327 // + if(!ApplicationIsBorderless) + windowStyle |= WS_DLGFRAME | WS_CAPTION | WS_SYSMENU; + // =================== Community Fix End ================= + else windowStyle |= WS_EX_TOPMOST | WS_SYSMENU; @@ -901,6 +912,12 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, //added a preparse step for this flag because it affects window creation style if (stricmp(token,"-win")==0) ApplicationIsWindowed=true; + // =================== Community Fix Start ================= + // Borderless Support - PR #327 // + if(stricmp(token,"-noborder")==0) + ApplicationIsBorderless=true; + // =================== Community Fix End ================= + token = nextParam(NULL, "\" "); } diff --git a/GeneralsMD/Code/Main/WinMain.cpp b/GeneralsMD/Code/Main/WinMain.cpp index c07319742b..831465788c 100644 --- a/GeneralsMD/Code/Main/WinMain.cpp +++ b/GeneralsMD/Code/Main/WinMain.cpp @@ -78,6 +78,12 @@ HINSTANCE ApplicationHInstance = NULL; ///< our application instance HWND ApplicationHWnd = NULL; ///< our application window handle Bool ApplicationIsWindowed = false; + + // =================== Community Fix Start ================= + // Borderless Support - PR #327 // +Bool ApplicationIsBorderless = false; + // =================== Community Fix End ================= + Win32Mouse *TheWin32Mouse= NULL; ///< for the WndProc() only DWORD TheMessageTime = 0; ///< For getting the time that a message was posted from Windows. @@ -696,7 +702,12 @@ static Bool initializeAppWindows( HINSTANCE hInstance, Int nCmdShow, Bool runWin // Create our main window windowStyle = WS_POPUP|WS_VISIBLE; if (runWindowed) - windowStyle |= WS_DLGFRAME | WS_CAPTION | WS_SYSMENU; + // =================== Community Fix Start ================= + // Borderless Support - PR #327 // + if(!ApplicationIsBorderless) + windowStyle |= WS_DLGFRAME | WS_CAPTION | WS_SYSMENU; + // =================== Community Fix End ================= + else windowStyle |= WS_EX_TOPMOST | WS_SYSMENU; @@ -926,6 +937,13 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, //added a preparse step for this flag because it affects window creation style if (stricmp(token,"-win")==0) ApplicationIsWindowed=true; + + // =================== Community Fix Start ================= + // Borderless Support - PR #327 // + if(stricmp(token,"-noborder")==0) + ApplicationIsBorderless=true;) + // =================== Community Fix End ================= + token = nextParam(NULL, "\" "); } From 42e597bedf6ab151a209147c649e7b5315a73a48 Mon Sep 17 00:00:00 2001 From: Afevis Date: Tue, 4 Mar 2025 03:27:04 -0700 Subject: [PATCH 2/4] Comments --- Generals/Code/Main/WinMain.cpp | 17 +++-------------- GeneralsMD/Code/Main/WinMain.cpp | 18 +++--------------- 2 files changed, 6 insertions(+), 29 deletions(-) diff --git a/Generals/Code/Main/WinMain.cpp b/Generals/Code/Main/WinMain.cpp index effcc59245..c60f410add 100644 --- a/Generals/Code/Main/WinMain.cpp +++ b/Generals/Code/Main/WinMain.cpp @@ -75,12 +75,7 @@ HINSTANCE ApplicationHInstance = NULL; ///< our application instance HWND ApplicationHWnd = NULL; ///< our application window handle Bool ApplicationIsWindowed = false; - - // =================== Community Fix Start ================= - // Borderless Support - PR #327 // -Bool ApplicationIsBorderless = false; - // =================== Community Fix End ================= - +Bool ApplicationIsBorderless = false; // TheSuperHackers @feature @ShizCalev 04/04/2025 - Borderless Windowed support Win32Mouse *TheWin32Mouse= NULL; ///< for the WndProc() only DWORD TheMessageTime = 0; ///< For getting the time that a message was posted from Windows. @@ -680,12 +675,9 @@ static Bool initializeAppWindows( HINSTANCE hInstance, Int nCmdShow, Bool runWin // Create our main window windowStyle = WS_POPUP|WS_VISIBLE; if (runWindowed) - // =================== Community Fix Start ================= - // Borderless Support - PR #327 // + // TheSuperHackers @feature @ShizCalev 04/04/2025 - Borderless Windowed support if(!ApplicationIsBorderless) windowStyle |= WS_DLGFRAME | WS_CAPTION | WS_SYSMENU; - // =================== Community Fix End ================= - else windowStyle |= WS_EX_TOPMOST | WS_SYSMENU; @@ -912,12 +904,9 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, //added a preparse step for this flag because it affects window creation style if (stricmp(token,"-win")==0) ApplicationIsWindowed=true; - // =================== Community Fix Start ================= - // Borderless Support - PR #327 // + // TheSuperHackers @feature @ShizCalev 04/04/2025 - Borderless Windowed support if(stricmp(token,"-noborder")==0) ApplicationIsBorderless=true; - // =================== Community Fix End ================= - token = nextParam(NULL, "\" "); } diff --git a/GeneralsMD/Code/Main/WinMain.cpp b/GeneralsMD/Code/Main/WinMain.cpp index 831465788c..074eafee7c 100644 --- a/GeneralsMD/Code/Main/WinMain.cpp +++ b/GeneralsMD/Code/Main/WinMain.cpp @@ -78,12 +78,7 @@ HINSTANCE ApplicationHInstance = NULL; ///< our application instance HWND ApplicationHWnd = NULL; ///< our application window handle Bool ApplicationIsWindowed = false; - - // =================== Community Fix Start ================= - // Borderless Support - PR #327 // -Bool ApplicationIsBorderless = false; - // =================== Community Fix End ================= - +Bool ApplicationIsBorderless = false; // TheSuperHackers @feature @ShizCalev 04/04/2025 - Borderless Windowed support Win32Mouse *TheWin32Mouse= NULL; ///< for the WndProc() only DWORD TheMessageTime = 0; ///< For getting the time that a message was posted from Windows. @@ -702,12 +697,9 @@ static Bool initializeAppWindows( HINSTANCE hInstance, Int nCmdShow, Bool runWin // Create our main window windowStyle = WS_POPUP|WS_VISIBLE; if (runWindowed) - // =================== Community Fix Start ================= - // Borderless Support - PR #327 // + // TheSuperHackers @feature @ShizCalev 04/04/2025 - Borderless Windowed support if(!ApplicationIsBorderless) windowStyle |= WS_DLGFRAME | WS_CAPTION | WS_SYSMENU; - // =================== Community Fix End ================= - else windowStyle |= WS_EX_TOPMOST | WS_SYSMENU; @@ -937,13 +929,9 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, //added a preparse step for this flag because it affects window creation style if (stricmp(token,"-win")==0) ApplicationIsWindowed=true; - - // =================== Community Fix Start ================= - // Borderless Support - PR #327 // + // TheSuperHackers @feature @ShizCalev 04/04/2025 - Borderless Windowed support if(stricmp(token,"-noborder")==0) ApplicationIsBorderless=true;) - // =================== Community Fix End ================= - token = nextParam(NULL, "\" "); } From 865e14c223c4e100405d9e8002a464a07f6f2dfb Mon Sep 17 00:00:00 2001 From: Afevis Date: Sat, 8 Mar 2025 17:07:58 -0700 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Cody Brittain <1779662+Generalcamo@users.noreply.github.com> --- GeneralsMD/Code/Main/WinMain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GeneralsMD/Code/Main/WinMain.cpp b/GeneralsMD/Code/Main/WinMain.cpp index 074eafee7c..a8eb9c2783 100644 --- a/GeneralsMD/Code/Main/WinMain.cpp +++ b/GeneralsMD/Code/Main/WinMain.cpp @@ -931,7 +931,7 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, ApplicationIsWindowed=true; // TheSuperHackers @feature @ShizCalev 04/04/2025 - Borderless Windowed support if(stricmp(token,"-noborder")==0) - ApplicationIsBorderless=true;) + ApplicationIsBorderless=true; token = nextParam(NULL, "\" "); } From 36b7cf83ce89d4ca617b525b9f4d39290913bee7 Mon Sep 17 00:00:00 2001 From: Afevis Date: Mon, 19 May 2025 17:52:00 -0600 Subject: [PATCH 4/4] Apply suggestions from code review --- Generals/Code/Main/WinMain.cpp | 2 -- GeneralsMD/Code/Main/WinMain.cpp | 2 -- 2 files changed, 4 deletions(-) diff --git a/Generals/Code/Main/WinMain.cpp b/Generals/Code/Main/WinMain.cpp index c60f410add..72eb16248b 100644 --- a/Generals/Code/Main/WinMain.cpp +++ b/Generals/Code/Main/WinMain.cpp @@ -675,7 +675,6 @@ static Bool initializeAppWindows( HINSTANCE hInstance, Int nCmdShow, Bool runWin // Create our main window windowStyle = WS_POPUP|WS_VISIBLE; if (runWindowed) - // TheSuperHackers @feature @ShizCalev 04/04/2025 - Borderless Windowed support if(!ApplicationIsBorderless) windowStyle |= WS_DLGFRAME | WS_CAPTION | WS_SYSMENU; else @@ -904,7 +903,6 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, //added a preparse step for this flag because it affects window creation style if (stricmp(token,"-win")==0) ApplicationIsWindowed=true; - // TheSuperHackers @feature @ShizCalev 04/04/2025 - Borderless Windowed support if(stricmp(token,"-noborder")==0) ApplicationIsBorderless=true; token = nextParam(NULL, "\" "); diff --git a/GeneralsMD/Code/Main/WinMain.cpp b/GeneralsMD/Code/Main/WinMain.cpp index a8eb9c2783..a97da50a70 100644 --- a/GeneralsMD/Code/Main/WinMain.cpp +++ b/GeneralsMD/Code/Main/WinMain.cpp @@ -697,7 +697,6 @@ static Bool initializeAppWindows( HINSTANCE hInstance, Int nCmdShow, Bool runWin // Create our main window windowStyle = WS_POPUP|WS_VISIBLE; if (runWindowed) - // TheSuperHackers @feature @ShizCalev 04/04/2025 - Borderless Windowed support if(!ApplicationIsBorderless) windowStyle |= WS_DLGFRAME | WS_CAPTION | WS_SYSMENU; else @@ -929,7 +928,6 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, //added a preparse step for this flag because it affects window creation style if (stricmp(token,"-win")==0) ApplicationIsWindowed=true; - // TheSuperHackers @feature @ShizCalev 04/04/2025 - Borderless Windowed support if(stricmp(token,"-noborder")==0) ApplicationIsBorderless=true; token = nextParam(NULL, "\" ");