zoukankan      html  css  js  c++  java
  • C# enable为false时不变颜色

     1         [System.Runtime.InteropServices.DllImport("user32.dll ")]
     2         public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int wndproc);
     3         [System.Runtime.InteropServices.DllImport("user32.dll ")]
     4         public static extern int GetWindowLong(IntPtr hWnd, int nIndex);
     5  
     6         public const int GWL_STYLE = -16;
     7         public const int WS_DISABLED = 0x8000000;
     8  
     9         public static void SetControlEnabled(Control c, bool enabled)
    10         {
    11             if (enabled)
    12             { SetWindowLong(c.Handle, GWL_STYLE, (~WS_DISABLED) & GetWindowLong(c.Handle, GWL_STYLE)); }
    13             else
    14             { SetWindowLong(c.Handle, GWL_STYLE, WS_DISABLED + GetWindowLong(c.Handle, GWL_STYLE)); }
    15         }
    16  
    17         private void button2_Click(object sender, System.EventArgs e)
    18         {
    19             SetControlEnabled(this.button1, false);
    20             this.button1.ForeColor = Color.White;
    21         }
    这个操作不是直接改变Enable 而是去掉它的鼠标绑定
  • 相关阅读:
    1001.A+B for Matrices
    1016.火星A+B
    1468.Sharing
    1464.Hello World For U
    约瑟夫问题pascal程序
    约数研究pascal程序
    迷宫pascal程序
    魔法照片pascal程序
    均分纸牌pascal程序
    多项式输出pascal程序
  • 原文地址:https://www.cnblogs.com/zhangruifeng/p/9349161.html
Copyright © 2011-2022 走看看