zoukankan      html  css  js  c++  java
  • 界面进行暂时锁定[原]

            在项目中,有时对界面的控制是这样的,需要在当前界面操作未完成时不允许另外的界面进行操作,于是有了下面的代码:
     

     1    /// <summary>
     2    /// 控制系统维护界面当点击按钮时,对界面进行暂时锁定
     3    /// Add by: Maxc
     4    /// </summary>

     5    public class SetUserControlEnable
     6    {   
     7        [DllImport("user32.dll")]
     8        private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int wndproc);
     9
    10        [DllImport("user32.dll")]
    11        private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
    12
    13        private const int GWL_STYLE = -16;
    14        private const int WS_DISABLED = 0x8000000;
    15
    16        private static void SetControlEnabled(Control c, bool enabled)
    17        {
    18            if (enabled)
    19            { SetWindowLong(c.Handle, GWL_STYLE, (~WS_DISABLED) & GetWindowLong(c.Handle, GWL_STYLE)); }
    20            else
    21            { SetWindowLong(c.Handle, GWL_STYLE, WS_DISABLED + GetWindowLong(c.Handle, GWL_STYLE)); }
    22        }

    23
    24        当点击按钮的时候,让所有界面都被锁定 private void LockAllInterface()
    35
    36        点击之后,所有界面都被解锁 private void UnlockAllInterface()
    47    }

    通过上述代码就可实现想要的效果了。
  • 相关阅读:
    爱的火花
    为你祝福
    你有成功的强烈愿望吗?人格魅力应该是这样修养而成的
    爱已远走
    我要跳舞
    创业家比商业模式更重要
    月下独酌
    李珊(再帮别人名字作诗)
    分析MSSQL数据库的用户表数和记录数 (转载)
    几个常用的SharePoint对象模型的有用函数
  • 原文地址:https://www.cnblogs.com/winnxm/p/1086525.html
Copyright © 2011-2022 走看看