NotifyIcon.ShowBalloonTip 方法

定义

在任务栏中显示气球提示。Displays the balloon tip in the taskbar.

重载

ShowBalloonTip(Int32)

指定时间段内在任务栏中显示气球状提示。Displays a balloon tip in the taskbar for the specified time period.

ShowBalloonTip(Int32, String, String, ToolTipIcon)

在指定时间段内,在任务栏中显示具有指定标题、文本和图标的气球状提示。Displays a balloon tip with the specified title, text, and icon in the taskbar for the specified time period.

ShowBalloonTip(Int32)

指定时间段内在任务栏中显示气球状提示。Displays a balloon tip in the taskbar for the specified time period.

public:
 void ShowBalloonTip(int timeout);
public void ShowBalloonTip (int timeout);
member this.ShowBalloonTip : int -> unit
Public Sub ShowBalloonTip (timeout As Integer)

参数

timeout
Int32

气球状提示应显示的时间段,以毫秒为单位。The time period, in milliseconds, the balloon tip should display.


从 Windows Vista 开始,否决此参数。This parameter is deprecated as of Windows Vista. 现在通知显示时间是基于系统辅助功能设置。Notification display times are now based on system accessibility settings.

例外

timeout 小于 0。timeout is less than 0.

示例

下面的代码示例演示如何使用 ShowBalloonTip 方法。The following code example demonstrates how to use the ShowBalloonTip method. 若要运行此示例,请将示例代码粘贴到包含名为 notifyIcon1NotifyIcon 的 Windows 窗体中。To run this example, paste the example code into a Windows Form that contains a NotifyIcon named notifyIcon1. 从窗体的构造函数或 Load 事件处理方法调用 SetBalloonTipCall SetBalloonTip from the form's constructor or Load event-handling method.

private void SetBalloonTip()
{
    notifyIcon1.Icon = SystemIcons.Exclamation;
    notifyIcon1.BalloonTipTitle = "Balloon Tip Title";
    notifyIcon1.BalloonTipText = "Balloon Tip Text.";
    notifyIcon1.BalloonTipIcon = ToolTipIcon.Error;
    this.Click += new EventHandler(Form1_Click);
}

void Form1_Click(object sender, EventArgs e) 
{
    notifyIcon1.Visible = true;
    notifyIcon1.ShowBalloonTip(30000);
}
Private Sub SetBalloonTip()
    notifyIcon1.Icon = SystemIcons.Exclamation
    notifyIcon1.BalloonTipTitle = "Balloon Tip Title"
    notifyIcon1.BalloonTipText = "Balloon Tip Text."
    notifyIcon1.BalloonTipIcon = ToolTipIcon.Error

End Sub

Sub Form1_Click(ByVal sender As Object, ByVal e As EventArgs) _
    Handles Me.Click

    notifyIcon1.Visible = True
    notifyIcon1.ShowBalloonTip(30000)

End Sub

注解

最小和最大超时值是由操作系统强制执行的,并且通常分别为10和30秒,但这可能因操作系统而异。Minimum and maximum timeout values are enforced by the operating system and are typically 10 and 30 seconds, respectively, however this can vary depending on the operating system. 超时值太大或太小会调整到适当的最小值或最大值。Timeout values that are too large or too small are adjusted to the appropriate minimum or maximum value. 此外,如果用户似乎没有使用计算机(没有键盘或鼠标事件发生),则系统不会将此时间计入超时值。In addition, if the user does not appear to be using the computer (no keyboard or mouse events are occurring) then the system does not count this time towards the timeout.

任务栏上每次只能显示一个气球状提示。Only one balloon tip can display on the taskbar at a time. 如果任务栏当前显示一个气球状提示,则会导致忽略 timeout 值。Attempting to display a balloon tip when one is currently displayed on the taskbar causes the timeout value to be ignored. 此行为稍有不同,具体取决于操作系统以及气球提示是来自其他还是相同的应用程序。The behavior is slightly different depending on the operating system and whether the balloon tip is from another, or the same, application. 当第二个气球提示来自其他应用程序时,将在第二个气球提示显示最小超时值,而不考虑 timeout的值。When the second balloon tip is from another application, the first balloon tip will display for the minimum timeout value before the second appears, regardless of the value of timeout. 在大多数情况下,如果气球提示来自同一应用程序,则在调用 ShowBalloonTip 方法时,第一个气球提示会立即关闭。In most cases, if the balloon tips are from the same application, the first balloon tip immediately closes when another call to the ShowBalloonTip method is made. 在某些情况下,第二个气球会在第一个气球顶部打开。In some cases the second balloon will open on top of the first balloon.

标题文本将以粗体显示在气球顶部附近。The title text will display in a bold font near the top of the balloon.

ShowBalloonTip(Int32, String, String, ToolTipIcon)

在指定时间段内,在任务栏中显示具有指定标题、文本和图标的气球状提示。Displays a balloon tip with the specified title, text, and icon in the taskbar for the specified time period.

public:
 void ShowBalloonTip(int timeout, System::String ^ tipTitle, System::String ^ tipText, System::Windows::Forms::ToolTipIcon tipIcon);
public void ShowBalloonTip (int timeout, string tipTitle, string tipText, System.Windows.Forms.ToolTipIcon tipIcon);
member this.ShowBalloonTip : int * string * string * System.Windows.Forms.ToolTipIcon -> unit
Public Sub ShowBalloonTip (timeout As Integer, tipTitle As String, tipText As String, tipIcon As ToolTipIcon)

参数

timeout
Int32

气球状提示应显示的时间段,以毫秒为单位。The time period, in milliseconds, the balloon tip should display.


从 Windows Vista 开始,否决此参数。This parameter is deprecated as of Windows Vista. 现在通知显示时间是基于系统辅助功能设置。Notification display times are now based on system accessibility settings.

tipTitle
String

要在气球状提示上显示的标题。The title to display on the balloon tip.

tipText
String

要在气球状提示上显示的文本。The text to display on the balloon tip.

tipIcon
ToolTipIcon

ToolTipIcon 值之一。One of the ToolTipIcon values.

例外

timeout 小于 0。timeout is less than 0.

tipTextnull 或空字符串。tipText is null or an empty string.

tipIcon 不是 ToolTipIcon 的成员。tipIcon is not a member of ToolTipIcon.

示例

下面的代码示例演示如何使用 ShowBalloonTip 方法。The following code example demonstrates how to use the ShowBalloonTip method. 若要运行此示例,请将示例代码粘贴到包含名为 notifyIcon1NotifyIcon 的 Windows 窗体中。To run this example, paste the example code into a Windows Form that contains a NotifyIcon named notifyIcon1. 将此示例中的 Form1_DoubleClick 方法与窗体的 DoubleClick 事件关联。Associate the Form1_DoubleClick method in this example with the form's DoubleClick event.

void Form1_DoubleClick(object sender, EventArgs e)
{
    notifyIcon1.Visible = true;
    notifyIcon1.ShowBalloonTip(20000, "Information", "This is the text",
        ToolTipIcon.Info );
}
Sub Form1_DoubleClick(ByVal sender As Object, ByVal e As EventArgs) _
        Handles Me.DoubleClick

    notifyIcon1.Visible = True
    notifyIcon1.ShowBalloonTip(20000, "Information", "This is the text", _
            ToolTipIcon.Info)
End Sub

注解

最小和最大超时值是由操作系统强制执行的,并且通常分别为10和30秒,但这可能因操作系统而异。Minimum and maximum timeout values are enforced by the operating system and are typically 10 and 30 seconds, respectively, however this can vary depending on the operating system. 超时值太大或太小会调整到适当的最小值或最大值。Timeout values that are too large or too small are adjusted to the appropriate minimum or maximum value. 此外,如果用户似乎没有使用计算机(没有键盘或鼠标事件发生),则系统不会将此时间计入超时值。In addition, if the user does not appear to be using the computer (no keyboard or mouse events are occurring) then the system does not count this time towards the timeout.

任务栏上每次只能显示一个气球状提示。Only one balloon tip can display on the taskbar at a time. 如果任务栏当前显示一个气球状提示,则会导致忽略 timeout 值。Attempting to display a balloon tip when one is currently displayed on the taskbar causes the timeout value to be ignored. 此行为稍有不同,具体取决于操作系统以及气球提示是来自其他还是相同的应用程序。The behavior is slightly different depending on the operating system and whether the balloon tip is from another, or the same, application. 当第二个气球提示来自其他应用程序时,将在第二个气球提示显示最小超时值,而不考虑 timeout的值。When the second balloon tip is from another application, the first balloon tip will display for the minimum timeout value before the second appears, regardless of the value of timeout. 在大多数情况下,如果气球提示来自同一应用程序,则在调用 ShowBalloonTip 方法时,第一个气球提示会立即关闭。In most cases, if the balloon tips are from the same application, the first balloon tip immediately closes when another call to the ShowBalloonTip method is made. 在某些情况下,第二个气球会在第一个气球顶部打开。In some cases the second balloon will open on top of the first balloon.

标题文本将以粗体显示在气球顶部附近。The title text will display in a bold font near the top of the balloon.

适用于