/// <summary> /// Invokes <see cref="WinApi.Shell_NotifyIcon"/> in order to display /// a given balloon ToolTip. /// </summary> /// <param name="title">The title to display on the balloon tip.</param> /// <param name="message">The text to display on the balloon tip.</param> /// <param name="flags">Indicates what icon to use.</param> /// <param name="balloonIconHandle">A handle to a custom icon, if any, or /// <see cref="IntPtr.Zero"/>.</param> private void ShowBalloonTip(string title, string message, BalloonFlags flags, IntPtr balloonIconHandle) { EnsureNotDisposed(); iconData.BalloonText = message ?? String.Empty; iconData.BalloonTitle = title ?? String.Empty; iconData.BalloonFlags = flags; iconData.CustomBalloonIconHandle = balloonIconHandle; Util.WriteIconData(ref iconData, NotifyCommand.Modify, IconDataMembers.Info | IconDataMembers.Icon); }
/// <summary> /// Invokes <see cref="WinApi.Shell_NotifyIcon"/> in order to display /// a given balloon ToolTip. /// </summary> /// <param name="title">The title to display on the balloon tip.</param> /// <param name="message">The text to display on the balloon tip.</param> /// <param name="flags">Indicates what icon to use.</param> /// <param name="balloonIconHandle">A handle to a custom icon, if any, or /// <see cref="IntPtr.Zero"/>.</param> private void ShowBalloonTip(string title, string message, BalloonFlags flags, IntPtr balloonIconHandle) { if (this.IsDisposed) { throw new ObjectDisposedException(this.Name ?? this.GetType().FullName); } iconData.BalloonText = message ?? string.Empty; iconData.BalloonTitle = title ?? string.Empty; iconData.BalloonFlags = flags; iconData.CustomBalloonIconHandle = balloonIconHandle; Util.WriteIconData(ref iconData, NotifyCommand.Modify, IconDataMembers.Info | IconDataMembers.Icon); }
/// <summary> /// Invokes <see cref="WinApi.Shell_NotifyIcon"/> in order to display /// a given balloon ToolTip. /// </summary> /// <param name="title">The title to display on the balloon tip.</param> /// <param name="message">The text to display on the balloon tip.</param> /// <param name="flags">Indicates what icon to use.</param> /// <param name="balloonIconHandle">A handle to a custom icon, if any, or /// <see cref="IntPtr.Zero"/>.</param> private void ShowBalloonTip(string title, string message, BalloonFlags flags, IntPtr balloonIconHandle) { EnsureNotDisposed(); iconData.BalloonText = message ?? String.Empty; iconData.BalloonTitle = title ?? String.Empty; iconData.BalloonFlags = flags; iconData.CustomBalloonIconHandle = balloonIconHandle; //var w = new System.Diagnostics.Stopwatch(); //w.Start(); Util.WriteIconData(ref iconData, NotifyCommand.Modify, IconDataMembers.Info | IconDataMembers.Icon); //Console.WriteLine($"------ {w.Elapsed}"); }
/// <summary> /// Displays a balloon tip with the specified title, /// text, and a custom icon in the taskbar for the specified time period. /// </summary> /// <param name="title">The title to display on the balloon tip.</param> /// <param name="message">The text to display on the balloon tip.</param> /// <param name="customIcon">A custom icon.</param> /// <param name="largeIcon">True to allow large icons (Windows Vista and later).</param> /// <exception cref="ArgumentNullException">If <paramref name="customIcon"/> /// is a null reference.</exception> public void ShowBalloonTip(string title, string message, Icon customIcon, bool largeIcon = false) { if (customIcon == null) { throw new ArgumentNullException("customIcon"); } lock (this) { BalloonFlags flags = BalloonFlags.User; if (largeIcon) { flags |= BalloonFlags.LargeIcon; } ShowBalloonTip(title, message, flags, customIcon.Handle); } }
/// <summary> /// Displays a balloon tip with the specified title, /// text, and a custom icon in the taskbar for the specified time period. /// </summary> /// <param name="title">The title to display on the balloon tip.</param> /// <param name="message">The text to display on the balloon tip.</param> /// <param name="customIcon">A custom icon.</param> /// <param name="largeIcon">True to allow large icons (Windows Vista and later).</param> /// <exception cref="ArgumentNullException">If <paramref name="customIcon"/> /// is a null reference.</exception> public void ShowBalloonTip(string title, string message, Icon customIcon, bool largeIcon = false) { if (customIcon == null) { throw new ArgumentNullException(nameof(customIcon)); } lock (lockObject) { BalloonFlags flags = BalloonFlags.User; if (largeIcon) { // ReSharper disable once BitwiseOperatorOnEnumWithoutFlags flags |= BalloonFlags.LargeIcon; } ShowBalloonTip(title, message, flags, customIcon.Handle); } }
/// <summary> /// Invokes <see cref="WinApi.Shell_NotifyIcon"/> in order to display /// a given balloon ToolTip. /// </summary> /// <param name="title">The title to display on the balloon tip.</param> /// <param name="message">The text to display on the balloon tip.</param> /// <param name="flags">Indicates what icon to use.</param> /// <param name="balloonIconHandle">A handle to a custom icon, if any, or /// <see cref="IntPtr.Zero"/>.</param> private void ShowBalloonTip(string title, string message, BalloonFlags flags, IntPtr balloonIconHandle) { if (this.IsDisposed) throw new ObjectDisposedException(this.Name ?? this.GetType().FullName); iconData.BalloonText = message ?? string.Empty; iconData.BalloonTitle = title ?? string.Empty; iconData.BalloonFlags = flags; iconData.CustomBalloonIconHandle = balloonIconHandle; Util.WriteIconData(ref iconData, NotifyCommand.Modify, IconDataMembers.Info | IconDataMembers.Icon); }