C#:Win32 Hooks(二)让MessageBox自动显示在父窗体中心

同系列文章:

/* ----------------------------------------------------------
文件名称:MessageBoxPlus.cs

作者:秦建辉

MSN:splashcn@msn.com
QQ:36748897

博客:http://www.firstsolver.com

开发环境:
    Visual Studio V2010
    .NET Framework 4 Client Profile

版本历史:
    V1.0	2012年05月07日			
            让MessageBox自动显示在父窗体中心
------------------------------------------------------------ */
using System;
using System.Windows.Forms;

namespace Splash.Windows.Forms
{
    public class MessageBoxPlus
    {
        public static DialogResult Show(IWin32Window owner, String text)
        {
            owner.CenterChild();
            return MessageBox.Show(owner, text);
        }

        public static DialogResult Show(IWin32Window owner, String text, String caption)
        {
            owner.CenterChild();
            return MessageBox.Show(owner, text, caption);
        }

        public static DialogResult Show(IWin32Window owner, String text, String caption, MessageBoxButtons buttons)
        {
            owner.CenterChild();
            return MessageBox.Show(owner, text, caption, buttons);
        }

        public static DialogResult Show(IWin32Window owner, String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon)
        {
            owner.CenterChild();
            return MessageBox.Show(owner, text, caption, buttons, icon);
        }

        public static DialogResult Show(IWin32Window owner, String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defButton)
        {
            owner.CenterChild();
            return MessageBox.Show(owner, text, caption, buttons, icon, defButton);
        }

        public static DialogResult Show(IWin32Window owner, String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defButton, MessageBoxOptions options)
        {
            owner.CenterChild();
            return MessageBox.Show(owner, text, caption, buttons, icon, defButton, options);
        }

        public static DialogResult Show(IWin32Window owner, String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, String helpFilePath)
        {
            owner.CenterChild();
            return MessageBox.Show(owner, text, caption, buttons, icon, defaultButton, options, helpFilePath);
        }

        public static DialogResult Show(IWin32Window owner, String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, String helpFilePath, String keyword)
        {
            owner.CenterChild();
            return MessageBox.Show(owner, text, caption, buttons, icon, defaultButton, options, helpFilePath, keyword);
        }

        public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, HelpNavigator navigator)
        {
            owner.CenterChild();
            return MessageBox.Show(owner, text, caption, buttons, icon, defaultButton, options, helpFilePath, navigator);
        }

        public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, HelpNavigator navigator, Object param)
        {
            owner.CenterChild();
            return MessageBox.Show(owner, text, caption, buttons, icon, defaultButton, options, helpFilePath, navigator, param);
        }
    }
}

Comments are closed.