简体   繁体   English

将应用程序最小化到系统任务栏-不显示图标

[英]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). 但是启动该应用程序后,该图标从任务栏消失(很好),但我在系统任务栏中看不到它(这很糟糕)。

在此处输入图片说明

Where can be a mistake, please? 请问哪里可能有错误? PS: i am using WPF. PS:我正在使用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;
            }

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: 该信息图标用于气球,而不是TrayIcon本身,您应该将图像(我建议使用16x16px png文件)添加到应用程序资源中,然后可以像这样使用它:

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

您需要设置图标,如下所示:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM