user7968180
user7968180

Reputation: 155

minimize app to system tray - no icon appears

i need to minimize app to system tray (see my icon there). But after starting the app, the icon dissapears from taskbar (that is fine) but i cannot see it in system tray (that is bad).

enter image description here

Where can be a mistake, please? PS: i am using WPF.

This is inner code of my event:

System.Windows.Forms.NotifyIcon notifyIcon = new System.Windows.Forms.NotifyIcon();
            if (WindowState.Minimized == this.WindowState)
            {
                notifyIcon.Visible = true;
                notifyIcon.BalloonTipText = "Radek app";
                notifyIcon.BalloonTipTitle = "Welcome Message";
                notifyIcon.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info;                
                notifyIcon.ShowBalloonTip(3000);                
                this.ShowInTaskbar = false;
            }

            else if (WindowState.Normal == this.WindowState)
            {
                this.WindowState = WindowState.Normal;
                this.ShowInTaskbar = true;
                notifyIcon.Visible = false;
            }

Upvotes: 1

Views: 672

Answers (2)

Mohamad Rashidi
Mohamad Rashidi

Reputation: 317

That Info icon is for the balloon, not the TrayIcon itself, you should add your image (I recommend 16x16px png file) to your application resources, then you can use it like:

var iconHandle = Properties.Resources.YourIconImage.GetHicon();
NotifyIcon.Icon = System.Drawing.Icon.FromHandle(iconHandle);

Upvotes: 3

Abhishek
Abhishek

Reputation: 2945

You need to set the Icon as shown below:

notifyIcon.Icon = new System.Drawing.Icon(Path to your Icon);

Upvotes: 2

Related Questions