zoukankan      html  css  js  c++  java
  • WPF 禁用窗体最大最小按键

     /// <summary>
        /// 禁用窗体最大最小按键
        /// </summary>
        internal static class WindowExtensions
        {
            [DllImport("user32.dll")]
            internal extern static int SetWindowLong(IntPtr hwnd, int index, int value);
    
            [DllImport("user32.dll")]
            internal extern static int GetWindowLong(IntPtr hwnd, int index);
    
            internal static void HideMinimizeAndMaximizeButtons(System.Windows.Window window)
            {
                const int GWL_STYLE = -16;
    
                IntPtr hwnd = new System.Windows.Interop.WindowInteropHelper(window).Handle;
                long value = GetWindowLong(hwnd, GWL_STYLE);
    
                SetWindowLong(hwnd, GWL_STYLE, (int)(value & -131073 & -65537));
    
            }
    
            internal static void DisableMinimizeButton(System.Windows.Window window)
            {
                const int GWL_STYLE = -16;
                IntPtr hwnd = new System.Windows.Interop.WindowInteropHelper(window).Handle;
                long value = GetWindowLong(hwnd, GWL_STYLE);
    
                SetWindowLong(hwnd, GWL_STYLE, (int)(value & -131073));
            }
    
            internal static void DisableMaximizeButton(System.Windows.Window window)
            {
                const int GWL_STYLE = -16;
                IntPtr hwnd = new System.Windows.Interop.WindowInteropHelper(window).Handle;
                long value = GetWindowLong(hwnd, GWL_STYLE);
    
                SetWindowLong(hwnd, GWL_STYLE, (int)(value & -65537 & -131073));
            }
        }
    

      用法

     public Window2()
            {
                InitializeComponent();
                this.SourceInitialized += (x, y) =>
                {
                    WindowExtensions.DisableMinimizeButton(this);
                };
            }
    

      

  • 相关阅读:
    正则表达式的学习笔记
    apply()的使用
    for循环性能测试
    js基础复习~Array对象
    判断值是否为undefined
    layui 单选框取消选中
    layui 表单验证
    火狐浏览器下,表头边框无效
    css3 宽度百分比减去固定宽度 无效问题
    javaScript中的 call 和 apply
  • 原文地址:https://www.cnblogs.com/wangyonglai/p/13712344.html
Copyright © 2011-2022 走看看