Last active
January 11, 2022 19:15
-
-
Save fravelgue/1c72c83b70893626129d9dec395fdd0b to your computer and use it in GitHub Desktop.
Windows C# Remove title bar to any application
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Diagnostics; | |
using System.Runtime.InteropServices; | |
using static WinApi; | |
var process = Process.GetProcessesByName(args.FirstOrDefault()).FirstOrDefault(); | |
if (process == null) | |
return; | |
var style = GetWindowLong(process.MainWindowHandle, GWL_STYLE); | |
SetWindowLong(process.MainWindowHandle, GWL_STYLE, (uint)style & ~WS_CAPTION); | |
static class WinApi | |
{ | |
public static readonly int GWL_STYLE = -16; | |
//Window Styles | |
public const uint WS_BORDER = 0x00800000; | |
public const uint WS_DLGFRAME = 0x00400000; | |
public const uint WS_CAPTION = WS_BORDER | WS_DLGFRAME; | |
public const uint WS_THICKFRAME = 0x00040000; | |
public const uint WS_MINIMIZE = 0x20000000; | |
public const uint WS_MAXIMIZE = 0x01000000; | |
public const uint WS_SYSMENU = 0x00080000; | |
public const uint WS_EX_DLGMODALFRAME = 0x00000001; | |
public const uint WS_EX_CLIENTEDGE = 0x00000200; | |
public const uint WS_EX_STATICEDGE = 0x00020000; | |
[DllImport("user32.dll")] | |
public static extern int GetWindowLong(IntPtr hWnd, int nIndex); | |
[DllImport("user32.dll")] | |
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, uint dwNewLong); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment