zoukankan      html  css  js  c++  java
  • 去掉关闭按钮同时禁用alt+f4进行关闭

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

  • 相关阅读:
    css3
    ubuntu /mac 终端命令大全
    MarkDown的语法的简要规则
    向github上传一个项目
    datatable 去掉默认功能
    datatable 自定义筛选
    vuex
    es6入门教程
    datatable 指定添加排序,根据列的值来设置颜色
    在ios上块点击出现闪黑底
  • 原文地址:https://www.cnblogs.com/chiyueqi/p/5497371.html
Copyright © 2011-2022 走看看