Created
June 22, 2017 22:03
-
-
Save sachintha81/26129460b20659dcd1b08aa206207b36 to your computer and use it in GitHub Desktop.
WPF Hide Window Close Button (Red X Button)
This file contains 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; | |
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); | |
[DllImport("user32.dll")] | |
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); | |
public ProgressBarWindow() | |
{ | |
InitializeComponent(); | |
} | |
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
It doesnt work:(