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    }

    通过上述代码就可实现想要的效果了。
  • 相关阅读:
    Laravel 如何在blade文件中使用Vue组件
    历史上的今天mysql数据库包含详情分类以及图片
    【问题】多重继承时,super函数只初始化继承的第一个类,不初始化第二个类。
    pretty-errors:美化python异常输出以使其清晰易读
    python 安装pyinstaller
    python制作ico图标
    Unofficial Windows Binaries for Python Extension Packages
    【转载】wav文件格式分析与详解
    C语言结构体定义位域,从bit0开始,依次到最高bit位
    IP切换脚本
  • 原文地址:https://www.cnblogs.com/winnxm/p/1086525.html
Copyright © 2011-2022 走看看