1
yhj
2024-07-24 5e5d945e91568b973faa27d8ab0bcef99fc4a6c5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System;
using System.Windows.Forms;
using CSFrameworkV5.Common;
 
namespace CSFrameworkV5.Library
{
    /// <summary>
    /// 等待窗体(已过时),请使用frmWaitingEx
    /// </summary>
    public partial class frmWaiting : Form
    {
 
        private static frmWaiting _Instance = null;
 
        public frmWaiting()
        {
            InitializeComponent();
 
            WinAPI.SetClassLong(this.Handle, WinAPI.GCL_STYLE,
                WinAPI.GetClassLong(this.Handle, WinAPI.GCL_STYLE) | WinAPI.CS_DropSHADOW); //API函数加载,实现窗体边框阴影效果
        }
 
        public void ShowWaitingMessage(string msg)
        {
            lblMsg.Text = msg;
            lblMsg.Invalidate();
        }
 
        public static void ShowMe(Form owner)
        {
            ShowMe(owner, "", false);
        }
 
        public static void ShowMe(Form owner, string message)
        {
            ShowMe(owner, message, false);
        }
 
        public static void ShowMe(Form owner, string message, bool disableOwner)
        {
            if (owner != null)
            {
                owner.Cursor = Cursors.WaitCursor;//调用窗体显示等待光标
                owner.Enabled = !disableOwner;
            }
 
            if (_Instance == null)
            {
                CCursor.ShowWaitCursor();
                _Instance = new frmWaiting();
                _Instance.Owner = owner;
                _Instance.Show();
            }
 
            if (message != "")
            {
                _Instance.lblMsg.Text = String.IsNullOrEmpty(message) ? _Instance.lblMsg.Text : message;
                _Instance.lblMsg.Invalidate();
            }
 
            Application.DoEvents();//刷新当前进程
        }
 
        public static void HideMe(Form owner)
        {
            if (_Instance != null)
            {
                _Instance.Close();
                _Instance = null;
            }
 
            if (owner != null)
            {
                owner.Focus();
                owner.Cursor = Cursors.Default;
            }
        }
 
        private void frmWaiting_FormClosed(object sender, FormClosedEventArgs e)
        {
            _Instance = null;
        }
 
    }
}