Processing Ajax...

Title

Message

Confirm

Confirm

Confirm

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure?

Remove Windows Top Title Bar

Description
This script will remove the caption bar from the focused window.
Language
C#.net
Minimum Version
Created By
Matthew P.
Contributors
-
Date Created
12d ago
Date Last Modified
12d ago

Scripted Function (Macro) Code

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!");
    }
}