Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
WPF Hide Window Close Button (Red X Button)
using System;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
namespace KawasakiLogConverter
/// <summary>
/// Interaction logic for ProgressBarWindow.xaml
/// </summary>
public partial class ProgressBarWindow : Window
private const int GWL_STYLE = -16;
private const int WS_SYSMENU = 0x80000;
[DllImport("user32.dll", SetLastError = true)]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
public ProgressBarWindow()
private void Window_Loaded(object sender, RoutedEventArgs e)
var hwnd = new WindowInteropHelper(this).Handle;
SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.