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

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

using System.Runtime.InteropServices;  public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int wndproc); 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(button1, false); button1.ForeColor = Color.White; }

 

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

你可能感兴趣的文章
python之元组
查看>>
python之元组
查看>>
Python之列表和元组
查看>>
python之判断一个值是不是可以被调用
查看>>
python之处理excel表格
查看>>
python之字符串【str】
查看>>
Python之并发请求 (干货)
查看>>
python之异常处理
查看>>
python之异常处理
查看>>
Python之杨辉三角算法实现
查看>>
Python之格式化输出讲解
查看>>
python之网络编程1-socket-tcp与udp
查看>>
Python之美[从菜鸟到高手]--Python垃圾回收机制及gc模块详解
查看>>
python之装饰器
查看>>
Python之路,Day18 - 开发一个WEB聊天来撩妹吧
查看>>
python之路--初识函数
查看>>
python接口自动化测试之接口数据依赖
查看>>
python之路-09-文件操作
查看>>
python之路-基础篇-第五周
查看>>
python之路-字符串
查看>>