System.Windows.Forms命名空间的MessageBox.show()用法大全

摘要:
    //     显示消息窗口(也称为对话框)向用户展示消息。 这是一个模式窗口,可阻止应用程序中的其他操作,直到用户将其关闭。 System.Windows.Forms.MessageBox
    //     可包含通知并指示用户的文本、按钮和符号。

//
// 摘要:
//     显示一个具有指定文本、标题、按钮、图标、默认按钮、选项和“帮助”按钮的消息框。
//
// 参数:
//   text:
//     要在消息框中显示的文本。
//
//   caption:
//     要在消息框的标题栏中显示的文本。
//
//   buttons:
//     System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中显示哪些按钮。
//
//   icon:
//     System.Windows.Forms.MessageBoxIcon 值之一,它指定在消息框中显示哪个图标。
//
//   defaultButton:
//     System.Windows.Forms.MessageBoxDefaultButton 值之一,可指定消息框中的默认按钮。
//
//   options:
//     System.Windows.Forms.MessageBoxOptions 值之一,可指定将对消息框使用哪些显示和关联选项。 若要使用默认值,请传入 0。
//
//   displayHelpButton:
//     如果显示“帮助”按钮,则为 true;否则为 false。 默认值为 false。
//
// 返回结果:
//     System.Windows.Forms.DialogResult 值之一。
//
// 异常:
//   T:System.ComponentModel.InvalidEnumArgumentException:
//     buttons 不是成员的 System.Windows.Forms.MessageBoxButtons。 - 或 - icon 不是成员的 System.Windows.Forms.MessageBoxIcon。
//     - 或 - defaultButton 指定不是成员的 System.Windows.Forms.MessageBoxDefaultButton。
//
//   T:System.InvalidOperationException:
//     尝试显示 System.Windows.Forms.MessageBox 在没有用户交互模式中运行的进程中。 这通过指定 System.Windows.Forms.SystemInformation.UserInteractive
//     属性。
//
//   T:System.ArgumentException:
//     options 指定同时 System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly 和 System.Windows.Forms.MessageBoxOptions.ServiceNotification。
//     - 或 - buttons 指定了无效的组合 System.Windows.Forms.MessageBoxButtons。
public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, bool displayHelpButton);
//
// 摘要:
//     在指定对象的前面显示具有指定文本、标题和按钮的消息框。
//
// 参数:
//   owner:
//     将拥有模式对话框的 System.Windows.Forms.IWin32Window 的一个实现。
//
//   text:
//     要在消息框中显示的文本。
//
//   caption:
//     要在消息框的标题栏中显示的文本。
//
//   buttons:
//     System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中显示哪些按钮。
//
// 返回结果:
//     System.Windows.Forms.DialogResult 值之一。
//
// 异常:
//   T:System.ComponentModel.InvalidEnumArgumentException:
//     buttons 不是成员的 System.Windows.Forms.MessageBoxButtons。
//
//   T:System.InvalidOperationException:
//     尝试显示 System.Windows.Forms.MessageBox 在没有用户交互模式中运行的进程中。 这通过指定 System.Windows.Forms.SystemInformation.UserInteractive
//     属性。
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons);
//
// 摘要:
//     在指定对象的前面显示具有指定文本、标题、按钮和图标的消息框。
//
// 参数:
//   owner:
//     将拥有模式对话框的 System.Windows.Forms.IWin32Window 的一个实现。
//
//   text:
//     要在消息框中显示的文本。
//
//   caption:
//     要在消息框的标题栏中显示的文本。
//
//   buttons:
//     System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中显示哪些按钮。
//
//   icon:
//     System.Windows.Forms.MessageBoxIcon 值之一,它指定在消息框中显示哪个图标。
//
// 返回结果:
//     System.Windows.Forms.DialogResult 值之一。
//
// 异常:
//   T:System.ComponentModel.InvalidEnumArgumentException:
//     buttons 不是成员的 System.Windows.Forms.MessageBoxButtons。 - 或 - icon 不是成员的 System.Windows.Forms.MessageBoxIcon。
//
//   T:System.InvalidOperationException:
//     尝试显示 System.Windows.Forms.MessageBox 在没有用户交互模式中运行的进程中。 这通过指定 System.Windows.Forms.SystemInformation.UserInteractive
//     属性。
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon);
//
// 摘要:
//     在指定对象的前面显示具有指定文本、标题、按钮、图标和默认按钮的消息框。
//
// 参数:
//   owner:
//     将拥有模式对话框的 System.Windows.Forms.IWin32Window 的一个实现。
//
//   text:
//     要在消息框中显示的文本。
//
//   caption:
//     要在消息框的标题栏中显示的文本。
//
//   buttons:
//     System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中显示哪些按钮。
//
//   icon:
//     System.Windows.Forms.MessageBoxIcon 值之一,它指定在消息框中显示哪个图标。
//
//   defaultButton:
//     System.Windows.Forms.MessageBoxDefaultButton 值之一,可指定消息框中的默认按钮。
//
// 返回结果:
//     System.Windows.Forms.DialogResult 值之一。
//
// 异常:
//   T:System.ComponentModel.InvalidEnumArgumentException:
//     buttons 不是成员的 System.Windows.Forms.MessageBoxButtons。 - 或 - icon 不是成员的 System.Windows.Forms.MessageBoxIcon。
//     - 或 - defaultButton 不是成员的 System.Windows.Forms.MessageBoxDefaultButton。
//
//   T:System.InvalidOperationException:
//     尝试显示 System.Windows.Forms.MessageBox 在没有用户交互模式中运行的进程中。 这通过指定 System.Windows.Forms.SystemInformation.UserInteractive
//     属性。
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton);
//
// 摘要:
//     在指定对象的前面显示具有指定文本、标题、按钮、图标、默认按钮和选项的消息框。
//
// 参数:
//   owner:
//     将拥有模式对话框的 System.Windows.Forms.IWin32Window 的一个实现。
//
//   text:
//     要在消息框中显示的文本。
//
//   caption:
//     要在消息框的标题栏中显示的文本。
//
//   buttons:
//     System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中显示哪些按钮。
//
//   icon:
//     System.Windows.Forms.MessageBoxIcon 值之一,它指定在消息框中显示哪个图标。
//
//   defaultButton:
//     System.Windows.Forms.MessageBoxDefaultButton 值之一,可指定消息框的默认按钮。
//
//   options:
//     System.Windows.Forms.MessageBoxOptions 值之一,可指定将对消息框使用哪些显示和关联选项。 若要使用默认值,请传入 0。
//
// 返回结果:
//     System.Windows.Forms.DialogResult 值之一。
//
// 异常:
//   T:System.ComponentModel.InvalidEnumArgumentException:
//     buttons 不是成员的 System.Windows.Forms.MessageBoxButtons。 - 或 - icon 不是成员的 System.Windows.Forms.MessageBoxIcon。
//     - 或 - defaultButton 不是成员的 System.Windows.Forms.MessageBoxDefaultButton。
//
//   T:System.InvalidOperationException:
//     尝试显示 System.Windows.Forms.MessageBox 在没有用户交互模式中运行的进程中。 这通过指定 System.Windows.Forms.SystemInformation.UserInteractive
//     属性。
//
//   T:System.ArgumentException:
//     options 指定同时 System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly 和 System.Windows.Forms.MessageBoxOptions.ServiceNotification。
//     - 或 - options 指定 System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly 或
//     System.Windows.Forms.MessageBoxOptions.ServiceNotification 指定中的值和 owner 参数。 仅当调用不采用此方法的版本,则应使用这两个选项
//     owner 参数。 - 或 - buttons 指定了无效的组合 System.Windows.Forms.MessageBoxButtons。
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options);
//
// 摘要:
//     显示具有指定文本的消息框。
//
// 参数:
//   text:
//     要在消息框中显示的文本。
//
// 返回结果:
//     System.Windows.Forms.DialogResult 值之一。
public static DialogResult Show(string text);
//
// 摘要:
//     显示具有指定文本和标题的消息框。
//
// 参数:
//   text:
//     要在消息框中显示的文本。
//
//   caption:
//     要在消息框的标题栏中显示的文本。
//
// 返回结果:
//     System.Windows.Forms.DialogResult 值之一。
public static DialogResult Show(string text, string caption);
//
// 摘要:
//     显示具有指定文本、标题和按钮的消息框。
//
// 参数:
//   text:
//     要在消息框中显示的文本。
//
//   caption:
//     要在消息框的标题栏中显示的文本。
//
//   buttons:
//     System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中显示哪些按钮。
//
// 返回结果:
//     System.Windows.Forms.DialogResult 值之一。
//
// 异常:
//   T:System.ComponentModel.InvalidEnumArgumentException:
//     buttons 指定的参数不是成员的 System.Windows.Forms.MessageBoxButtons。
//
//   T:System.InvalidOperationException:
//     尝试显示 System.Windows.Forms.MessageBox 在没有用户交互模式中运行的进程中。 这通过指定 System.Windows.Forms.SystemInformation.UserInteractive
//     属性。
public static DialogResult Show(string text, string caption, MessageBoxButtons buttons);
//
// 摘要:
//     显示具有指定文本、标题、按钮和图标的消息框。
//
// 参数:
//   text:
//     要在消息框中显示的文本。
//
//   caption:
//     要在消息框的标题栏中显示的文本。
//
//   buttons:
//     System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中显示哪些按钮。
//
//   icon:
//     System.Windows.Forms.MessageBoxIcon 值之一,它指定在消息框中显示哪个图标。
//
// 返回结果:
//     System.Windows.Forms.DialogResult 值之一。
//
// 异常:
//   T:System.ComponentModel.InvalidEnumArgumentException:
//     buttons 指定的参数不是成员的 System.Windows.Forms.MessageBoxButtons。 - 或 - icon 指定的参数不是成员的
//     System.Windows.Forms.MessageBoxIcon。
//
//   T:System.InvalidOperationException:
//     尝试显示 System.Windows.Forms.MessageBox 在没有用户交互模式中运行的进程中。 这通过指定 System.Windows.Forms.SystemInformation.UserInteractive
//     属性。
public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon);
//
// 摘要:
//     在指定对象的前面显示具有指定文本和标题的消息框。
//
// 参数:
//   owner:
//     将拥有模式对话框的 System.Windows.Forms.IWin32Window 的一个实现。
//
//   text:
//     要在消息框中显示的文本。
//
//   caption:
//     要在消息框的标题栏中显示的文本。
//
// 返回结果:
//     System.Windows.Forms.DialogResult 值之一。
public static DialogResult Show(IWin32Window owner, string text, string caption);
//
// 摘要:
//     显示具有指定文本、标题、按钮、图标和默认按钮的消息框。
//
// 参数:
//   text:
//     要在消息框中显示的文本。
//
//   caption:
//     要在消息框的标题栏中显示的文本。
//
//   buttons:
//     System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中显示哪些按钮。
//
//   icon:
//     System.Windows.Forms.MessageBoxIcon 值之一,它指定在消息框中显示哪个图标。
//
//   defaultButton:
//     System.Windows.Forms.MessageBoxDefaultButton 值之一,可指定消息框中的默认按钮。
//
// 返回结果:
//     System.Windows.Forms.DialogResult 值之一。
//
// 异常:
//   T:System.ComponentModel.InvalidEnumArgumentException:
//     buttons 不是成员的 System.Windows.Forms.MessageBoxButtons。 - 或 - icon 不是成员的 System.Windows.Forms.MessageBoxIcon。
//     - 或 - defaultButton 不是成员的 System.Windows.Forms.MessageBoxDefaultButton。
//
//   T:System.InvalidOperationException:
//     尝试显示 System.Windows.Forms.MessageBox 在没有用户交互模式中运行的进程中。 这通过指定 System.Windows.Forms.SystemInformation.UserInteractive
//     属性。
public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton);
//
// 摘要:
//     使用指定的帮助文件、HelpNavigator 和帮助主题显示一个具有指定文本、标题、按钮、图标、默认按钮、选项和“帮助”按钮的消息框。
//
// 参数:
//   owner:
//     将拥有模式对话框的 System.Windows.Forms.IWin32Window 的一个实现。
//
//   text:
//     要在消息框中显示的文本。
//
//   caption:
//     要在消息框的标题栏中显示的文本。
//
//   buttons:
//     System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中显示哪些按钮。
//
//   icon:
//     System.Windows.Forms.MessageBoxIcon 值之一,它指定在消息框中显示哪个图标。
//
//   defaultButton:
//     System.Windows.Forms.MessageBoxDefaultButton 值之一,可指定消息框中的默认按钮。
//
//   options:
//     System.Windows.Forms.MessageBoxOptions 值之一,可指定将对消息框使用哪些显示和关联选项。 若要使用默认值,请传入 0。
//
//   helpFilePath:
//     用户单击“帮助”按钮时显示的“帮助”文件的路径和名称。
//
//   navigator:
//     System.Windows.Forms.HelpNavigator 值之一。
//
//   param:
//     用户单击“帮助”按钮时显示的帮助主题的数值 ID。
//
// 返回结果:
//     System.Windows.Forms.DialogResult 值之一。
//
// 异常:
//   T:System.ComponentModel.InvalidEnumArgumentException:
//     buttons 不是成员的 System.Windows.Forms.MessageBoxButtons。 - 或 - icon 不是成员的 System.Windows.Forms.MessageBoxIcon。
//     - 或 - defaultButton 指定不是成员的 System.Windows.Forms.MessageBoxDefaultButton。
//
//   T:System.InvalidOperationException:
//     尝试显示 System.Windows.Forms.MessageBox 在没有用户交互模式中运行的进程中。 这通过指定 System.Windows.Forms.SystemInformation.UserInteractive
//     属性。
//
//   T:System.ArgumentException:
//     options 指定同时 System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly 和 System.Windows.Forms.MessageBoxOptions.ServiceNotification。
//     - 或 - buttons 指定了无效的组合 System.Windows.Forms.MessageBoxButtons。
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, HelpNavigator navigator, object param);
//
// 摘要:
//     使用指定的帮助文件、HelpNavigator 和帮助主题显示一个具有指定文本、标题、按钮、图标、默认按钮、选项和“帮助”按钮的消息框。
//
// 参数:
//   text:
//     要在消息框中显示的文本。
//
//   caption:
//     要在消息框的标题栏中显示的文本。
//
//   buttons:
//     System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中显示哪些按钮。
//
//   icon:
//     System.Windows.Forms.MessageBoxIcon 值之一,它指定在消息框中显示哪个图标。
//
//   defaultButton:
//     System.Windows.Forms.MessageBoxDefaultButton 值之一,可指定消息框中的默认按钮。
//
//   options:
//     System.Windows.Forms.MessageBoxOptions 值之一,可指定将对消息框使用哪些显示和关联选项。 若要使用默认值,请传入 0。
//
//   helpFilePath:
//     用户单击“帮助”按钮时显示的“帮助”文件的路径和名称。
//
//   navigator:
//     System.Windows.Forms.HelpNavigator 值之一。
//
//   param:
//     用户单击“帮助”按钮时显示的帮助主题的数值 ID。
//
// 返回结果:
//     System.Windows.Forms.DialogResult 值之一。
//
// 异常:
//   T:System.ComponentModel.InvalidEnumArgumentException:
//     buttons 不是成员的 System.Windows.Forms.MessageBoxButtons。 - 或 - icon 不是成员的 System.Windows.Forms.MessageBoxIcon。
//     - 或 - defaultButton 指定不是成员的 System.Windows.Forms.MessageBoxDefaultButton。
//
//   T:System.InvalidOperationException:
//     尝试显示 System.Windows.Forms.MessageBox 在没有用户交互模式中运行的进程中。 这通过指定 System.Windows.Forms.SystemInformation.UserInteractive
//     属性。
//
//   T:System.ArgumentException:
//     options 指定同时 System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly 和 System.Windows.Forms.MessageBoxOptions.ServiceNotification。
//     - 或 - buttons 指定了无效的组合 System.Windows.Forms.MessageBoxButtons。
public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, HelpNavigator navigator, object param);
//
// 摘要:
//     使用指定的帮助文件和 HelpNavigator 显示一个具有指定文本、标题、按钮、图标、默认按钮、选项和“帮助”按钮的消息框。
//
// 参数:
//   owner:
//     将拥有模式对话框的 System.Windows.Forms.IWin32Window 的一个实现。
//
//   text:
//     要在消息框中显示的文本。
//
//   caption:
//     要在消息框的标题栏中显示的文本。
//
//   buttons:
//     System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中显示哪些按钮。
//
//   icon:
//     System.Windows.Forms.MessageBoxIcon 值之一,它指定在消息框中显示哪个图标。
//
//   defaultButton:
//     System.Windows.Forms.MessageBoxDefaultButton 值之一,可指定消息框中的默认按钮。
//
//   options:
//     System.Windows.Forms.MessageBoxOptions 值之一,可指定将对消息框使用哪些显示和关联选项。 若要使用默认值,请传入 0。
//
//   helpFilePath:
//     用户单击“帮助”按钮时显示的“帮助”文件的路径和名称。
//
//   navigator:
//     System.Windows.Forms.HelpNavigator 值之一。
//
// 返回结果:
//     System.Windows.Forms.DialogResult 值之一。
//
// 异常:
//   T:System.ComponentModel.InvalidEnumArgumentException:
//     buttons 不是成员的 System.Windows.Forms.MessageBoxButtons。 - 或 - icon 不是成员的 System.Windows.Forms.MessageBoxIcon。
//     - 或 - defaultButton 指定不是成员的 System.Windows.Forms.MessageBoxDefaultButton。
//
//   T:System.InvalidOperationException:
//     尝试显示 System.Windows.Forms.MessageBox 在没有用户交互模式中运行的进程中。 这通过指定 System.Windows.Forms.SystemInformation.UserInteractive
//     属性。
//
//   T:System.ArgumentException:
//     options 指定同时 System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly 和 System.Windows.Forms.MessageBoxOptions.ServiceNotification。
//     - 或 - buttons 指定了无效的组合 System.Windows.Forms.MessageBoxButtons。
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, HelpNavigator navigator);
//
// 摘要:
//     使用指定的帮助文件和 HelpNavigator 显示一个具有指定文本、标题、按钮、图标、默认按钮、选项和“帮助”按钮的消息框。
//
// 参数:
//   text:
//     要在消息框中显示的文本。
//
//   caption:
//     要在消息框的标题栏中显示的文本。
//
//   buttons:
//     System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中显示哪些按钮。
//
//   icon:
//     System.Windows.Forms.MessageBoxIcon 值之一,它指定在消息框中显示哪个图标。
//
//   defaultButton:
//     System.Windows.Forms.MessageBoxDefaultButton 值之一,可指定消息框中的默认按钮。
//
//   options:
//     System.Windows.Forms.MessageBoxOptions 值之一,可指定将对消息框使用哪些显示和关联选项。 若要使用默认值,请传入 0。
//
//   helpFilePath:
//     用户单击“帮助”按钮时显示的“帮助”文件的路径和名称。
//
//   navigator:
//     System.Windows.Forms.HelpNavigator 值之一。
//
// 返回结果:
//     System.Windows.Forms.DialogResult 值之一。
//
// 异常:
//   T:System.ComponentModel.InvalidEnumArgumentException:
//     buttons 不是成员的 System.Windows.Forms.MessageBoxButtons。 - 或 - icon 不是成员的 System.Windows.Forms.MessageBoxIcon。
//     - 或 - defaultButton 指定不是成员的 System.Windows.Forms.MessageBoxDefaultButton。
//
//   T:System.InvalidOperationException:
//     尝试显示 System.Windows.Forms.MessageBox 在没有用户交互模式中运行的进程中。 这通过指定 System.Windows.Forms.SystemInformation.UserInteractive
//     属性。
//
//   T:System.ArgumentException:
//     options 指定同时 System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly 和 System.Windows.Forms.MessageBoxOptions.ServiceNotification。
//     - 或 - buttons 指定了无效的组合 System.Windows.Forms.MessageBoxButtons。
public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, HelpNavigator navigator);
//
// 摘要:
//     使用指定的帮助文件和帮助关键字显示一个具有指定文本、标题、按钮、图标、默认按钮、选项和“帮助”按钮的消息框。
//
// 参数:
//   owner:
//     将拥有模式对话框的 System.Windows.Forms.IWin32Window 的一个实现。
//
//   text:
//     要在消息框中显示的文本。
//
//   caption:
//     要在消息框的标题栏中显示的文本。
//
//   buttons:
//     System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中显示哪些按钮。
//
//   icon:
//     System.Windows.Forms.MessageBoxIcon 值之一,它指定在消息框中显示哪个图标。
//
//   defaultButton:
//     System.Windows.Forms.MessageBoxDefaultButton 值之一,可指定消息框中的默认按钮。
//
//   options:
//     System.Windows.Forms.MessageBoxOptions 值之一,可指定将对消息框使用哪些显示和关联选项。 若要使用默认值,请传入 0。
//
//   helpFilePath:
//     用户单击“帮助”按钮时显示的“帮助”文件的路径和名称。
//
//   keyword:
//     在用户单击“帮助”按钮时显示的帮助关键字。
//
// 返回结果:
//     System.Windows.Forms.DialogResult 值之一。
//
// 异常:
//   T:System.ComponentModel.InvalidEnumArgumentException:
//     buttons 不是成员的 System.Windows.Forms.MessageBoxButtons。 - 或 - icon 不是成员的 System.Windows.Forms.MessageBoxIcon。
//     - 或 - defaultButton 指定不是成员的 System.Windows.Forms.MessageBoxDefaultButton。
//
//   T:System.InvalidOperationException:
//     尝试显示 System.Windows.Forms.MessageBox 在没有用户交互模式中运行的进程中。 这通过指定 System.Windows.Forms.SystemInformation.UserInteractive
//     属性。
//
//   T:System.ArgumentException:
//     options 指定同时 System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly 和 System.Windows.Forms.MessageBoxOptions.ServiceNotification。
//     - 或 - buttons 指定了无效的组合 System.Windows.Forms.MessageBoxButtons。
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, string keyword);
//
// 摘要:
//     使用指定的帮助文件和帮助关键字显示一个具有指定文本、标题、按钮、图标、默认按钮、选项和“帮助”按钮的消息框。
//
// 参数:
//   text:
//     要在消息框中显示的文本。
//
//   caption:
//     要在消息框的标题栏中显示的文本。
//
//   buttons:
//     System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中显示哪些按钮。
//
//   icon:
//     System.Windows.Forms.MessageBoxIcon 值之一,它指定在消息框中显示哪个图标。
//
//   defaultButton:
//     System.Windows.Forms.MessageBoxDefaultButton 值之一,可指定消息框中的默认按钮。
//
//   options:
//     System.Windows.Forms.MessageBoxOptions 值之一,可指定将对消息框使用哪些显示和关联选项。 若要使用默认值,请传入 0。
//
//   helpFilePath:
//     用户单击“帮助”按钮时显示的“帮助”文件的路径和名称。
//
//   keyword:
//     在用户单击“帮助”按钮时显示的帮助关键字。
//
// 返回结果:
//     System.Windows.Forms.DialogResult 值之一。
//
// 异常:
//   T:System.ComponentModel.InvalidEnumArgumentException:
//     buttons 不是成员的 System.Windows.Forms.MessageBoxButtons。 - 或 - icon 不是成员的 System.Windows.Forms.MessageBoxIcon。
//     - 或 - defaultButton 指定不是成员的 System.Windows.Forms.MessageBoxDefaultButton。
//
//   T:System.InvalidOperationException:
//     尝试显示 System.Windows.Forms.MessageBox 在没有用户交互模式中运行的进程中。 这通过指定 System.Windows.Forms.SystemInformation.UserInteractive
//     属性。
//
//   T:System.ArgumentException:
//     options 指定同时 System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly 和 System.Windows.Forms.MessageBoxOptions.ServiceNotification。
//     - 或 - buttons 指定了无效的组合 System.Windows.Forms.MessageBoxButtons。
public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, string keyword);
//
// 摘要:
//     使用指定的帮助文件显示一个具有指定文本、标题、按钮、图标、默认按钮、选项和“帮助”按钮的消息框。
//
// 参数:
//   owner:
//     将拥有模式对话框的 System.Windows.Forms.IWin32Window 的一个实现。
//
//   text:
//     要在消息框中显示的文本。
//
//   caption:
//     要在消息框的标题栏中显示的文本。
//
//   buttons:
//     System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中显示哪些按钮。
//
//   icon:
//     System.Windows.Forms.MessageBoxIcon 值之一,它指定在消息框中显示哪个图标。
//
//   defaultButton:
//     System.Windows.Forms.MessageBoxDefaultButton 值之一,可指定消息框中的默认按钮。
//
//   options:
//     System.Windows.Forms.MessageBoxOptions 值之一,可指定将对消息框使用哪些显示和关联选项。 若要使用默认值,请传入 0。
//
//   helpFilePath:
//     用户单击“帮助”按钮时显示的“帮助”文件的路径和名称。
//
// 返回结果:
//     System.Windows.Forms.DialogResult 值之一。
//
// 异常:
//   T:System.ComponentModel.InvalidEnumArgumentException:
//     buttons 不是成员的 System.Windows.Forms.MessageBoxButtons。 - 或 - icon 不是成员的 System.Windows.Forms.MessageBoxIcon。
//     - 或 - defaultButton 指定不是成员的 System.Windows.Forms.MessageBoxDefaultButton。
//
//   T:System.InvalidOperationException:
//     尝试显示 System.Windows.Forms.MessageBox 在没有用户交互模式中运行的进程中。 这通过指定 System.Windows.Forms.SystemInformation.UserInteractive
//     属性。
//
//   T:System.ArgumentException:
//     options 指定同时 System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly 和 System.Windows.Forms.MessageBoxOptions.ServiceNotification。
//     - 或 - buttons 指定了无效的组合 System.Windows.Forms.MessageBoxButtons。
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath);
//
// 摘要:
//     使用指定的帮助文件显示一个具有指定文本、标题、按钮、图标、默认按钮、选项和“帮助”按钮的消息框。
//
// 参数:
//   text:
//     要在消息框中显示的文本。
//
//   caption:
//     要在消息框的标题栏中显示的文本。
//
//   buttons:
//     System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中显示哪些按钮。
//
//   icon:
//     System.Windows.Forms.MessageBoxIcon 值之一,它指定在消息框中显示哪个图标。
//
//   defaultButton:
//     System.Windows.Forms.MessageBoxDefaultButton 值之一,可指定消息框中的默认按钮。
//
//   options:
//     System.Windows.Forms.MessageBoxOptions 值之一,可指定将对消息框使用哪些显示和关联选项。 若要使用默认值,请传入 0。
//
//   helpFilePath:
//     用户单击“帮助”按钮时显示的“帮助”文件的路径和名称。
//
// 返回结果:
//     System.Windows.Forms.DialogResult 值之一。
//
// 异常:
//   T:System.ComponentModel.InvalidEnumArgumentException:
//     buttons 不是成员的 System.Windows.Forms.MessageBoxButtons。 - 或 - icon 不是成员的 System.Windows.Forms.MessageBoxIcon。
//     - 或 - defaultButton 指定不是成员的 System.Windows.Forms.MessageBoxDefaultButton。
//
//   T:System.InvalidOperationException:
//     尝试显示 System.Windows.Forms.MessageBox 在没有用户交互模式中运行的进程中。 这通过指定 System.Windows.Forms.SystemInformation.UserInteractive
//     属性。
//
//   T:System.ArgumentException:
//     options 指定同时 System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly 和 System.Windows.Forms.MessageBoxOptions.ServiceNotification。
//     - 或 - buttons 指定了无效的组合 System.Windows.Forms.MessageBoxButtons。
public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath);
//
// 摘要:
//     显示具有指定文本、标题、按钮、图标、默认按钮和选项的消息框。
//
// 参数:
//   text:
//     要在消息框中显示的文本。
//
//   caption:
//     要在消息框的标题栏中显示的文本。
//
//   buttons:
//     System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中显示哪些按钮。
//
//   icon:
//     System.Windows.Forms.MessageBoxIcon 值之一,它指定在消息框中显示哪个图标。
//
//   defaultButton:
//     System.Windows.Forms.MessageBoxDefaultButton 值之一,可指定消息框中的默认按钮。
//
//   options:
//     System.Windows.Forms.MessageBoxOptions 值之一,可指定将对消息框使用哪些显示和关联选项。 若要使用默认值,请传入 0。
//
// 返回结果:
//     System.Windows.Forms.DialogResult 值之一。
//
// 异常:
//   T:System.ComponentModel.InvalidEnumArgumentException:
//     buttons 不是成员的 System.Windows.Forms.MessageBoxButtons。 - 或 - icon 不是成员的 System.Windows.Forms.MessageBoxIcon。
//     - 或 - defaultButton 指定不是成员的 System.Windows.Forms.MessageBoxDefaultButton。
//
//   T:System.InvalidOperationException:
//     尝试显示 System.Windows.Forms.MessageBox 在没有用户交互模式中运行的进程中。 这通过指定 System.Windows.Forms.SystemInformation.UserInteractive
//     属性。
//
//   T:System.ArgumentException:
//     options 指定同时 System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly 和 System.Windows.Forms.MessageBoxOptions.ServiceNotification。
//     - 或 - buttons 指定了无效的组合 System.Windows.Forms.MessageBoxButtons。
public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options);
//
// 摘要:
//     在指定对象的前面显示具有指定文本的消息框。
//
// 参数:
//   owner:
//     将拥有模式对话框的 System.Windows.Forms.IWin32Window 的一个实现。
//
//   text:
//     要在消息框中显示的文本。
//
// 返回结果:
//     System.Windows.Forms.DialogResult 值之一。
public static DialogResult Show(IWin32Window owner, string text);

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
C#[托盘]Form.cs.txt public partial class Form2 : Form { // private System.ComponentModel.Container components = null; private Icon mNetTrayIcon = new Icon("Icon1.ico"); private NotifyIcon TrayIcon; private ContextMenu notifyiconMnu; public Form2() { InitializeComponent(); this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(320, 560); //this.ControlBox = false; //this.MaximizeBox = false; ///this.MinimizeBox = false; this.Name = "Form2"; this.ShowInTaskbar = false; this.Text = "用Visual C#做托盘程序!"; //this.WindowState = System.Windows.Forms.FormWindowState.Minimized; this.Load += new System.EventHandler(Form2_Load); this.ResumeLayout(false); //设定托盘程序的各个属性 TrayIcon = new NotifyIcon(); TrayIcon.Icon = mNetTrayIcon; TrayIcon.Text = "用Visual C#做托盘程序" + "\n" + "作者:马金虎于2001.12.08"; TrayIcon.Visible = true; TrayIcon.Click += new System.EventHandler(this.click); //定义一个MenuItem数组,并把此数组同时赋值给ContextMenu对象 MenuItem[] mnuItms = new MenuItem[3]; mnuItms[0] = new MenuItem(); mnuItms[0].Text = "C#做托盘程序!"; mnuItms[0].Click += new System.EventHandler(this.showmessage); mnuItms[1] = new MenuItem("-"); mnuItms[2] = new MenuItem(); mnuItms[2].Text = "退出"; mnuItms[2].Click += new System.EventHandler(this.ExitSelect); mnuItms[2].DefaultItem = true; notifyiconMnu = new ContextMenu(mnuItms); TrayIcon.ContextMenu = notifyiconMnu; //为托盘程序加入设定好的ContextMenu对象 } //托盘程序中的事件响应 public void click(object sender, System.EventArgs e) { if (this.WindowState == FormWindowState.Minimized) { this.WindowState = FormWindowState.Normal; } } public void showmessage(object sender, System.EventArgs e) { MessageBox.Show("你点击了菜单的第一个选项"); } public void ExitSelect(object sender, System.EventArgs e) { //隐藏托盘程序中的图标 TrayIcon.Visible = false; //关闭系统 this.Close(); } private void Form2_Load(object sender, EventArgs e) { } } QQ:292258449
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Diagnostics; using System.Runtime.InteropServices; namespace exe_test { public partial class Form1 : Form { public Form1() { InitializeComponent(); } Process process = null; IntPtr appWin; private string exeName = ""; [DllImport("user32.dll", EntryPoint = "GetWindowThreadProcessId", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] private static extern long GetWindowThreadProcessId(long hWnd, long lpdwProcessId); [DllImport("user32.dll", SetLastError = true)] private static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport("user32.dll", SetLastError = true)] private static extern long SetParent(IntPtr hWndChild, IntPtr hWndNewParent); [DllImport("user32.dll", EntryPoint = "GetWindowLongA", SetLastError = true)] private static extern long GetWindowLong(IntPtr hwnd, int nIndex); [DllImport("user32.dll", EntryPoint = "SetWindowLongA", SetLastError = true)] private static extern long SetWindowLong(IntPtr hwnd, int nIndex, long dwNewLong); //private static extern int SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong); [DllImport("user32.dll", SetLastError = true)] private static extern long SetWindowPos(IntPtr hwnd, long hWndInsertAfter, long x, long y, long cx, long cy, long wFlags); [DllImport("user32.dll", SetLastError = true)] private static extern bool MoveWindow(IntPtr hwnd, int x, int y, int cx, int cy, bool repaint); [DllImport("user32.dll", EntryPoint = "PostMessageA", SetLastError = true)] private static extern bool PostMessage(IntPtr hwnd, uint Msg, long wParam, long lParam); private const int SWP_NOOWNERZORDER = 0x200; private const int SWP_NOREDRAW = 0x8; private const int SWP_NOZORDER = 0x4; private const int SWP_SHOWWINDOW = 0x0040; private const int WS_EX_MDICHILD = 0x40; private const int SWP_FRAMECHANGED = 0x20; private const int SWP_NOACTIVATE = 0x10; private const int SWP_ASYNCWINDOWPOS = 0x4000; private const int SWP_NOMOVE = 0x2; private const int SWP_NOSIZE = 0x1; private const int GWL_STYLE = (-16); private const int WS_VISIBLE = 0x10000000; private const int WM_CLOSE = 0x10; private const int WS_CHILD = 0x40000000; public string ExeName { get { return exeName; } set { exeName = value; } } private void button1_Click(object sender, EventArgs e) { this.exeName = @"calc.exe"; try { process = System.Diagnostics.Process.Start(this.exeName); process.WaitForInputIdle(); System.Threading.Thread.Sleep(150); appWin = process.MainWindowHandle; } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error"); } SetParent(appWin, this.splitContainer1.Panel2.Handle); MoveWindow(appWin, 0, 0, this.Width, this.Height, true); } } }
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Data.OleDb; namespace DormMIS { /// <summary> /// Form1 的摘要说明。 /// </summary> public class Login : System.Windows.Forms.Form { private System.Windows.Forms.Button btClose;//取消按钮 private System.Windows.Forms.Button btAdd; private System.Windows.Forms.TextBox password; private System.Windows.Forms.TextBox name; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label1; /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.Container components = null; private OleDbConnection oleConnection1 = null; public Login() { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); this.oleConnection1=new OleDbConnection(DormMIS.database.dbConnection.connection); // // TODO: 在 InitializeComponent 调用后添加任何构造函数代码 // } /// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows 窗体设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Login)); this.btClose = new System.Windows.Forms.Button(); this.btAdd = new System.Windows.Forms.Button(); this.password = new System.Windows.Forms.TextBox(); this.name = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // btClose // this.btClose.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.btClose.ForeColor = System.Drawing.Color.Black; this.btClose.Location = new System.Drawing.Point(168, 156); this.btClose.Name = "btClose"; this.btClose.Size = new System.Drawing.Size(75, 23); this.btClose.TabIndex = 20; this.btClose.Text = "取消"; this.btClose.Click += new System.EventHandler(this.btClose_Click); // // btAdd // this.btAdd.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.btAdd.ForeColor = System.Drawing.Color.Black; this.btAdd.Location = new System.Drawing.Point(48, 156); this.btAdd.Name = "btAdd"; this.btAdd.Size = new System.Drawing.Size(75, 23); this.btAdd.TabIndex = 19; this.btAdd.Text = "确定"; this.btAdd.Click += new System.EventHandler(this.btAdd_Click); // // password // this.password.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.password.Location = new System.Drawing.Point(128, 116); this.password.Name = "password"; this.password.PasswordChar = '*'; this.password.Size = new System.Drawing.Size(100, 21); this.password.TabIndex = 18; this.password.Text = "admin"; // // name // this.name.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.name.Location = new System.Drawing.Point(128, 76); this.name.Name = "name"; this.name.Size = new System.Drawing.Size(100, 21); this.name.TabIndex = 17; this.name.Text = "admin"; this.name.TextChanged += new System.EventHandler(this.name_TextChanged); // // label3 // this.label3.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label3.ForeColor = System.Drawing.Color.Black; this.label3.Location = new System.Drawing.Point(64, 116); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(56, 23); this.label3.TabIndex = 16; this.label3.Text = "密 码"; // // label2 // this.label2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label2.ForeColor = System.Drawing.Color.Black; this.label2.Location = new System.Drawing.Point(64, 76); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(56, 23); this.label2.TabIndex = 15; this.label2.Text = "用户名"; // // label1 // this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label1.ForeColor = System.Drawing.Color.Black; this.label1.Location = new System.Drawing.Point(40, 24); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(228, 28); this.label1.TabIndex = 14; this.label1.Text = "宿舍管理信息系统"; // // Login // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.BackColor = System.Drawing.Color.Ivory; this.ClientSize = new System.Drawing.Size(304, 210); this.Controls.Add(this.btClose); this.Controls.Add(this.btAdd); this.Controls.Add(this.password); this.Controls.Add(this.name); this.Controls.Add(this.label3); this.Controls.Add(this.label2); this.Controls.Add(this.label1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "Login"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "登录"; this.Load += new System.EventHandler(this.Login_Load); this.ResumeLayout(false); this.PerformLayout(); } #endregion /// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main() { Application.Run(new Login()); } private void btAdd_Click(object sender, System.EventArgs e) { if(name.Text.Trim()==""||password.Text.Trim()=="") MessageBox.Show("请输入用户名和密码","提示"); else { oleConnection1.Open(); OleDbCommand cmd=new OleDbCommand("",oleConnection1); string sql="select * from userinfo where UName='"+name.Text.Trim()+"' and PWD='"+password.Text.Trim()+"'"; cmd.CommandText=sql; if (null!=cmd.ExecuteScalar()) { //隐藏登录窗口 this.Visible=false; //创建并打开主界面 Main main=new Main(); main.Tag=this.FindForm(); OleDbDataReader dr; cmd.CommandText=sql; dr=cmd.ExecuteReader(); dr.Read(); main.statusBarPanel2.Text=name.Text.Trim(); main.ShowDialog(); } else MessageBox.Show("用户名或密码错误","警告"); } oleConnection1.Close(); } private void btClose_Click(object sender, System.EventArgs e) { this.Close(); } private void name_TextChanged(object sender, EventArgs e) { } } }

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值