public int ctype = 0;
Private Const INT Gwl_style =-16;
Private Const int ws_sysmenu = 0x80000;
[System.Runtime.InteropServices.DllImport ("user32.dll", SetLastError = True)]
private static extern int GetWindowLong (IntPtr hWnd, int nIndex);
[System.Runtime.InteropServices.DllImport ("User32.dll")]
private static extern int SetWindowLong (IntPtr hWnd, int nIndex, int dwnewlong);
private void Window_Loaded (object sender, RoutedEventArgs e)
{
var hwnd = new System.Windows.Interop.WindowInteropHelper (this). Handle;
SetWindowLong (hwnd, Gwl_style, GetWindowLong (hwnd, Gwl_style) & ~ws_sysmenu);
}
private void Window_closing (object sender, System.ComponentModel.CancelEventArgs e)
{
if (CType < 1)
E.cancel = true;
}
private void Btnsave_mouseup (object sender, MouseButtonEventArgs e)
{
Try
{
CType = 1;
}
catch (Exception ex)
{
MessageBox.Show (ex. Message, "Hint", Messageboxbutton.ok, Messageboximage.error);
}
}
private void Btncancel_mouseup (object sender, MouseButtonEventArgs e)
{
Environment.exit (0);
}
Remove the Close button and disable Alt+f4 to close