Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Simulating a WAIT WINDOW
Message
General information
Forum:
ASP.NET
Category:
Forms
Miscellaneous
Thread ID:
00854354
Message ID:
00855305
Views:
20
Don

Here is a WaitWindow class I wrote. I also sent the files to you in an email. Hook this up as a static variable of the BusinessForm just like MessageBox and you have a VFP style wait window.

BTW, I'm not able to position the wait window base on the MainForm coordinate which is how VFP does it. If anyone out there figure it out, please let me know.

Stephen
   public class aaWaitWindow : aaBaseForm
   {
      private System.Windows.Forms.Label lblMessage;
      /// <summary>
      /// Required designer variable.
      /// </summary>
      private System.ComponentModel.Container components = null;
      private string sMsg;
      private CMS.Main.Windows.Forms.aaTimer aaTimer1;
      private Form ParentWin;
      private int iTimeOutSeconds = 0;
      private int iElapsed = 0;

      public aaWaitWindow()
      {
         InitializeComponent();
      }


      public string Message
      {
         set
         {
            this.lblMessage.Text = value;
         }
         get
         {
            return this.lblMessage.Text;
         }
      }

      public void Show(IWin32Window ParentWin, string sMessage, int iTimeOut)
      {
         this.iTimeOutSeconds = iTimeOut;
         this.aaTimer1.Start();
         this.Show(ParentWin,sMessage);
      }

      /// <summary>
      /// Recommend overload to use
      /// </summary>
      /// <param name="ParentWin">The parent form</param>
      /// <param name="sMessage">Message to display</param>
      public void Show(IWin32Window ParentWin, string sMessage)
      {
         this.ParentWin = (Form) ParentWin;
         this.sMsg = sMessage;
         this.Show();
      }

      public void Show(string sMessage, int iTimeOut)
      {
         this.iTimeOutSeconds = iTimeOut;
         this.aaTimer1.Start();
         this.Show(sMessage);
      }

      /// <summary>
      /// If you use this overload, the message window will show up on the middle of the screen
      /// </summary>
      /// <param name="sMessage">Message to display</param>
      public void Show(string sMessage)
      {
         this.sMsg = sMessage;
         this.Show();
      }

      /// <summary>
      /// Hide the wait window
      /// </summary>
      public void Clear()
      {
         this.Hide();
      }

      /// <summary>
      /// Set the message and reposition the window
      /// </summary>
      /// <param name="sender"></param>
      /// <param name="e"></param>
      private void aaWaitWindow_Activated(object sender, System.EventArgs e)
      {
         this.SuspendLayout();
         this.lblMessage.Text = this.sMsg;
         this.Width = this.lblMessage.Width + 20;
         this.Height = this.lblMessage.Height;
         
         if (this.ParentWin != null)
         {
            this.Top = this.ParentWin.Top + 30;
            this.Left = this.ParentWin.Left + this.ParentWin.Width - this.Width - 30;
            //          this.Top = this.ParentWin.MdiParent.Top + 30;
            //          this.Left = this.ParentWin.MdiParent.Left + this.ParentWin.MdiParent.Width - this.Width - 30;
         }
         this.ResumeLayout();
      }

      /// <summary>
      /// Hide the wait window when timeout
      /// </summary>
      /// <param name="sender"></param>
      /// <param name="e"></param>
      private void aaTimer1_Tick(object sender, System.EventArgs e)
      {
         this.iElapsed += 1000;
         if (this.iElapsed >= this.iTimeOutSeconds * 1000)
         {
            this.Clear();
            this.aaTimer1.Stop();
            this.iElapsed = 0;
         }
      }
   }
}
Stephen Lee

--------------------------------
Too much to code
Too little time
--------------------------------
Previous
Reply
Map
View

Click here to load this message in the networking platform