设置控件Enable=false,控件颜色不变
2015-08-27 16:07
323 查看
[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; }
相关文章推荐
- php 构造函数的继承
- win10提示无法验证发布者所以windows已阻止此软件该怎么办?
- HBase 体系之 Write-ahead-Log
- JAVA并发编程8_线程池的使用
- 黑马程序员——多线程
- [leetcode] 128.Longest Consecutive Sequence
- nginx error_log 日志配置
- 【iOS知识学习】_iOS动态改变TableView Cell高度
- shell 语句的应用
- groovy WEB组件之文件上传
- 10. jQuery Callback 函数
- Linux netlink机制及示例
- 【java】定时器 Timer和TimerTask类
- cdlinux u盘启动怎么制作教程
- JAVA并发编程8_线程池的使用
- IOS第14天(2, Modal控制)
- #PCDATA和CDATA的区别
- 如何安装mysql
- js实现简易计算器功能
- linux的基础命令