예제 #1
0
 /// <summary>
 /// Shows a WindowsMessageBox with no caption.
 /// </summary>
 /// <param name="messageText">The text to display in the MessageBox body.  Use standard carriage returns to delimit line endings.</param>
 /// <param name="flags">Flags that determine the appearance and behavior of the MessageBox. See <see cref="WinMessageBoxFlags"/> for more information.</param>
 /// <returns>The result of the MessageBox. <see cref="WinMessageBoxResult"/></returns>
 public static WinMessageBoxResult Show(string messageText, WinMessageBoxFlags flags)
 {
     return(Show(messageText, string.Empty, flags, DEFAULT_CAPTURE_FOCUS));
 }
예제 #2
0
        static extern IntPtr GetForegroundWindow(); //returns HWND of the foreground window

        /// <summary>
        /// Shows a Windows MessageBox.  NOTE: this will pause the current window until it returns, whether it be in editor or player.
        /// </summary>
        /// <param name="messageText">The text to display in the MessageBox body.  Use standard carriage returns to delimit line endings.</param>
        /// <param name="messageCaption">The text to display in the header of the MessageBox.  Note: if you want to specify no caption, use
        ///     either <c>""</c> or <c>string.Empty</c> - specifying <c>null</c> results in the caption displaying as "Error."</param>
        /// <param name="flags">Flags that determine the appearance and behavior of the MessageBox. See <see cref="WinMessageBoxFlags"/> for more information.</param>
        /// <param name="captureFocus">Whether or not the MessageBox will capture focus from the window or not.</param>
        /// <returns>The result of the MessageBox. <see cref="WinMessageBoxResult"/></returns>
        public static WinMessageBoxResult Show(string messageText, string messageCaption, WinMessageBoxFlags flags, bool captureFocus)
        {
            IntPtr hWnd = GetForegroundWindow();

            if (!captureFocus)
            {
                hWnd = IntPtr.Zero;
            }
            int result = MessageBox(hWnd, messageText, messageCaption, (uint)flags);

            return((WinMessageBoxResult)result);
        }