winform禁用控件,但不让控件变为灰色
2016-04-25 15:55
211 查看
[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://bbs.csdn.net/topics/350241687
相关文章推荐
- 从此不求人:自主研发一套PHP前端开发框架(28)
- Codeforces Round #347 (Div. 2) B. Rebus(给你一个等式里面只含加减号凑出一个数)
- JS_基础回看_tag
- 就是那个在公司女同事之间风评也差到爆的秃驴。
- Android* 操作系统上的应用程序远程调试
- jQuery.offsetParent() 函数详解
- CSS自动换行、强制不换行、强制断行、超出显示省略号
- Spring MVC 通过@Value注解读取.properties配置
- 根据地址获取HTTP返回的状态码
- [IMX6DL]超声波模块KS103 Linux驱动源代码
- Ubuntu安装镜像
- C++ 语言宏定义函数的使用(定义单行和多行)
- 从此不求人:自主研发一套PHP前端开发框架(27)
- OpenCv学习笔记(五)--创建Mat矩阵对象常用的几种方式
- 微信展示
- maven的入门与测试
- SourceTree名词解释
- AIR开发手机 相关文档
- 更多C#网络学习资料
- 客户端-服务器模式(架构)