I assume you mean minimize to the System tray because you have talked about icons and message ballons?
The following code will set up a tray icon:
private void SetUpTrayIcon()
{
notifyIcon = new System.Windows.Forms.NotifyIcon();
notifyIcon.BalloonTipText = "Ballon minimize text";
notifyIcon.BalloonTipTitle = "Ballon minimize title";
notifyIcon.Text = "Icon hover text";
notifyIcon.Icon = new System.Drawing.Icon(
System.Reflection.Assembly.GetExecutingAssembly()
.GetManifestResourceStream("MyIcon.ico"));
notifyIcon.Click += new EventHandler(HandlerToMaximiseOnClick);
}
To show the icon in the tray (you may want to do this on the window state change event for example, do something like the following:
if (notifyIcon != null)
{
notifyIcon.Visible = true;
notifyIcon.ShowBalloonTip(2000);
}
To display a ballon on mouse hover you want to use the same code as above possibly in the mousemove for the icon.
Note: ShowBalloonTip is overloaded if you want to change the message at different points. The message the balloon displays will respect newlines eg Environment.NewLine can be added to it.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…