using System;
using System.Runtime.InteropServices;
public static class DisplayFusionFunction
{
private const int GWL_STYLE = -16;
private const int WS_CAPTION = 0x00C00000;
private const int SWP_FRAMECHANGED = 0x0020;
private const int SWP_NOMOVE = 0x0002;
private const int SWP_NOSIZE = 0x0001;
private const int SWP_NOZORDER = 0x0004;
[DllImport("user32.dll", SetLastError = true)]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll", SetLastError = true)]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
[DllImport("user32.dll", SetLastError = true)]
private static extern bool SetWindowPos(
IntPtr hWnd,
IntPtr hWndInsertAfter,
int X,
int Y,
int cx,
int cy,
uint uFlags
);
public static void Run(IntPtr windowHandle)
{
// Check for valid window handle
if (windowHandle == IntPtr.Zero)
{
BFS.Dialog.ShowMessageInfo("No valid window handle provided.");
return;
}
// Remove the caption style
int style = GetWindowLong(windowHandle, GWL_STYLE);
style &= ~WS_CAPTION;
SetWindowLong(windowHandle, GWL_STYLE, style);
// Update the window so changes are visible
SetWindowPos(
windowHandle,
IntPtr.Zero,
0, 0, 0, 0,
SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER
);
// Log a success message instead of showing a dialog
// BFS.Log.Info("Title bar removed on the selected window!");
}
}