Subversion Repositories DevTools

Rev

Rev 2153 | Blame | Compare with Previous | Last modification | View Log | RSS feed

using System;
using System.Windows.Forms;

namespace EA_ReqPro
{
        /// <summary>
        /// A wrapper for MessageBox class, that ensures the TopMost flag is set.
        /// WARNING - this uses an undocumented feature. It might stop working correctly in future
        /// versions of the .NET framework. We need the topmost flag to be set because the reqpro
        /// import/export works as a thread and any message boxes it throws up can get lost behind
        /// EA and other windows if the user is not paying attention to what is going on, or perhaps
        /// is using some other program while the EA window is minimized during a reqpro import/export.
        /// </summary>

   public class MessageBoxEx
   {
      private static int topMost = 0x40000;  // .NET v1.1 does not expose this in its MessageBoxOptions enumeration

      public static DialogResult Show(string msg)
      {
         return MessageBox.Show(msg, "", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, (MessageBoxOptions)topMost);
      }

      public static DialogResult Show(string msg, string caption)
      {
         return MessageBox.Show(msg, caption, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, (MessageBoxOptions)topMost);
      }

      public static DialogResult Show(string msg, string caption, MessageBoxButtons buttons)
      {
         return MessageBox.Show(msg, caption, buttons, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, (MessageBoxOptions)topMost);
      }

      public static DialogResult Show(string msg, string caption, MessageBoxIcon icon)
      {
         return MessageBox.Show(msg, caption, MessageBoxButtons.OK, icon, MessageBoxDefaultButton.Button1, (MessageBoxOptions)topMost);
      }


   }
}