博客
关于我
设置控件Enable=false,控件颜色不变
阅读量:419 次
发布时间:2019-03-06

本文共 888 字,大约阅读时间需要 2 分钟。

[System.Runtime.InteropServices.DllImport("user32.dll ")]        public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int wndproc);        [System.Runtime.InteropServices.DllImport("user32.dll ")]        public static extern int GetWindowLong(IntPtr hWnd, int nIndex);        public const int GWL_STYLE = -16;        public const int WS_DISABLED = 0x8000000;        public static void SetControlEnabled(Control c, bool enabled)        {            if (enabled)            { SetWindowLong(c.Handle, GWL_STYLE, (~WS_DISABLED) & GetWindowLong(c.Handle, GWL_STYLE)); }            else            { SetWindowLong(c.Handle, GWL_STYLE, WS_DISABLED + GetWindowLong(c.Handle, GWL_STYLE)); }        }        private void button2_Click(object sender, System.EventArgs e)        {            SetControlEnabled(this.button1, false);            this.button1.ForeColor = Color.White;        }

 

转载地址:http://rcvkz.baihongyu.com/

你可能感兴趣的文章
MySQL中interactive_timeout和wait_timeout的区别
查看>>
mysql中int、bigint、smallint 和 tinyint的区别、char和varchar的区别详细介绍
查看>>
mysql中json_extract的使用方法
查看>>
mysql中json_extract的使用方法
查看>>
mysql中kill掉所有锁表的进程
查看>>
mysql中like % %模糊查询
查看>>
MySql中mvcc学习记录
查看>>
mysql中null和空字符串的区别与问题!
查看>>