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, "提示", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void btnCancel_MouseUp(object sender, MouseButtonEventArgs e)
{
Environment.Exit(0);
}