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;
|
}
|
|
}
|
}
|