C#如何实现最小化后只在状态栏显示

 我来答
greystar_cn
2018-04-03 · 知道合伙人软件行家
greystar_cn
知道合伙人软件行家
采纳数:16407 获赞数:17260
本人主要从事.NET C#方向的技术开发工作,具有10多年的各类架构开发工作经验。

向TA提问 私信TA
展开全部
private void InitializeComponent_tray() { this.SuspendLayout(); this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(320, 56); this.ControlBox = false; this.MaximizeBox = false; this.MinimizeBox = false; this.WindowState = System.Windows.Forms.FormWindowState.Minimized; this.Name = "tray"; this.ShowInTaskbar = false; this.Text = "用Visual C#做托盘程序!"; this.ResumeLayout(false); } private Icon printIcon ;//打印图标 private NotifyIcon TrayIcon; private ContextMenu notifyiconMnu; private MenuItem[] mnuItms; /// <summary> /// 设置证书制作和打印为托盘程序 /// </summary> private void Initializenotifyicon() { CurrentMethod method = new CurrentMethod(); string first = method.ConfigGetValue("StartOrEnd"); //设定托盘程序的各个属性 TrayIcon = new NotifyIcon(); string str_path = string.Empty; str_path = System.Windows.Forms.Application.StartupPath + "\\" + "edit.ico"; printIcon = new Icon(str_path);//打印图标 TrayIcon.Icon = printIcon; TrayIcon.Text = "质检报告制作打印服务"; //定义一个MenuItem数组,并把此数组同时赋值给ContextMenu对象 mnuItms = new MenuItem[5]; if (first == "0")//开机自启动 { mnuItms[0] = new MenuItem(); mnuItms[0].Text = "开机不启动"; mnuItms[0].Click += new System.EventHandler(this.NoOpenStart); } else { mnuItms[0] = new MenuItem(); mnuItms[0].Text = "开机自启动"; mnuItms[0].Click += new System.EventHandler(this.OpenStart); } mnuItms[0].DefaultItem = true; mnuItms[1] = new MenuItem("-"); mnuItms[2] = new MenuItem(); mnuItms[2].Text = "打印机配置"; mnuItms[2].Click += new System.EventHandler(this.showmessage); mnuItms[2].DefaultItem = true; mnuItms[3] = new MenuItem("-"); //mnuItms[4] = new MenuItem(); //mnuItms[4].Text = "条码配置"; //mnuItms[4].Click += new System.EventHandler(this.Print_BarCode_Config); //mnuItms[4].DefaultItem = true; //mnuItms[5] = new MenuItem("-"); mnuItms[4] = new MenuItem(); mnuItms[4].Text = "退出系统"; mnuItms[4].Click += new System.EventHandler(this.ExitSelect); mnuItms[4].DefaultItem = true; TrayIcon.Visible = true; TrayIcon.Click += new System.EventHandler(this.click); notifyiconMnu = new ContextMenu(mnuItms); TrayIcon.ContextMenu = notifyiconMnu; //为托盘程序加入设定好的ContextMenu对象 }
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式