首页 > Windows开发 > 详细

转载 C#设置控件 Enabled 为 false 时背景色不改变

时间:2020-05-13 16:58:01      阅读:88      评论:0      收藏:0      [点我收藏+]
class CtrEnabled
{
    [System.Runtime.InteropServices.DllImport("user32.dll ")]
    static extern int SetWindowLong(IntPtr hWnd, int nIndex, int wndproc);
    [System.Runtime.InteropServices.DllImport("user32.dll ")]
    static extern int GetWindowLong(IntPtr hWnd, int nIndex);
 
    const int GWL_STYLE = -16;
    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));
        }
    }
 
}

转载于https://blog.csdn.net/breakbridge/article/details/103913246

转载 C#设置控件 Enabled 为 false 时背景色不改变

原文:https://www.cnblogs.com/xuezhu/p/12883192.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!