博客
关于我
设置控件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实现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贪婪的背包算法(附完整源码)
查看>>
Objective-C实现GridGet算法(附完整源码)
查看>>
Objective-C实现half adder半加器算法(附完整源码)
查看>>
Objective-C实现hamiltonianCycle哈密尔顿图算法(附完整源码)
查看>>
Objective-C实现hamming code汉明码算法(附完整源码)
查看>>
Objective-C实现hamming numbers汉明数算法(附完整源码)
查看>>
Objective-C实现hammingDistance汉明距离算法(附完整源码)
查看>>
Objective-C实现hanning 窗(附完整源码)
查看>>
Objective-C实现hanoiTower汉诺塔算法(附完整源码)
查看>>
Objective-C实现hardy ramanujana定理算法(附完整源码)
查看>>
Objective-C实现harmonic series调和级数算法(附完整源码)
查看>>
Objective-C实现harris算法(附完整源码)
查看>>