Beispiel #1
0
        /// <include file='doc\FileDialog.uex' path='docs/doc[@for="FileDialog.MessageBoxWithFocusRestore"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Prompts the user with a <see cref='System.Windows.Forms.MessageBox'/>
        ///       with the given parameters. It also ensures that
        ///       the focus is set back on the window that had
        ///       the focus to begin with (before we displayed
        ///       the MessageBox).
        ///    </para>
        /// </devdoc>
        internal bool MessageBoxWithFocusRestore(string message, string caption,
                                                 MessageBoxButtons buttons, MessageBoxIcon icon)
        {
            bool   ret;
            IntPtr focusHandle = UnsafeNativeMethods.GetFocus();

            try {
                ret = RTLAwareMessageBox.Show(null, message, caption, buttons, icon,
                                              MessageBoxDefaultButton.Button1, 0) == DialogResult.Yes;
            }
            finally {
                UnsafeNativeMethods.SetFocus(new HandleRef(null, focusHandle));
            }
            return(ret);
        }
Beispiel #2
0
        internal bool MessageBoxWithFocusRestore(string message, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
        {
            bool   flag;
            IntPtr focus = System.Windows.Forms.UnsafeNativeMethods.GetFocus();

            try
            {
                flag = RTLAwareMessageBox.Show(null, message, caption, buttons, icon, MessageBoxDefaultButton.Button1, 0) == DialogResult.Yes;
            }
            finally
            {
                System.Windows.Forms.UnsafeNativeMethods.SetFocus(new HandleRef(null, focus));
            }
            return(flag);
        }