博客
关于我
设置控件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/

你可能感兴趣的文章
Objective-C实现FTP上传文件(附完整源码)
查看>>
Objective-C实现FTP文件上传(附完整源码)
查看>>
Objective-C实现FTP文件下载(附完整源码)
查看>>
Objective-C实现fuzzy operations模糊运算算法(附完整源码)
查看>>
Objective-C实现Gale-Shapley盖尔-沙普利算法(附完整源码)
查看>>
Objective-C实现gamma recursive伽玛递归算法(附完整源码)
查看>>
Objective-C实现gamma 伽玛功能算法(附完整源码)
查看>>
Objective-C实现gauss easte高斯复活节日期算法(附完整源码)
查看>>
Objective-C实现gaussian filter高斯滤波器算法(附完整源码)
查看>>
Objective-C实现gaussian naive bayes高斯贝叶斯算法(附完整源码)
查看>>
Objective-C实现gaussian高斯算法(附完整源码)
查看>>
Objective-C实现geometric series几何系列算法(附完整源码)
查看>>
Objective-C实现getline函数功能(附完整源码)
查看>>
Objective-C实现gnome sortt侏儒排序算法(附完整源码)
查看>>
Objective-C实现graph list图列算法(附完整源码)
查看>>
Objective-C实现GraphEdge图边算法(附完整源码)
查看>>
Objective-C实现GraphVertex图顶点算法(附完整源码)
查看>>
Objective-C实现greatest common divisor最大公约数算法(附完整源码)
查看>>
Objective-C实现greedy coin change贪心硬币找零算法(附完整源码)
查看>>
Objective-C实现greedy knapsack贪婪的背包算法(附完整源码)
查看>>