为什么不能实现在托盘显示程序图标?
时间:2011-12-07
来源:互联网
using System; using System.Resources; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace 考试系统 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void btnLogon_Click(object sender, EventArgs e) { if (txtUserName.Text == "admin" && txtPassword.Text == "123") { MessageBox.Show("登陆成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); Form2 fs2= new Form2(); fs2.Show(); } else MessageBox.Show("登录失败", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } private void Form1_SizeChanged(object sender, EventArgs e) { } private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) { if (this.WindowState==FormWindowState.Minimized) { this.notifyIcon1.Visible=true; this.ShowInTaskbar = true; this.notifyIcon1.Visible = false; } } private void Form1_Load(object sender, EventArgs e) { notifyIcon1.Visible = false; } private void Form1_MinimumSizeChanged(object sender, EventArgs e) { this.Hide(); this.ShowInTaskbar = false; this.notifyIcon1.Visible = true; } } }
这个代码中 为什么不能实现程序最小化到托盘,而不在任务栏显示;当点击托盘图标,程序重新恢复任务栏显示?
作者: ds2009w 发布时间: 2011-12-07
{
this.notifyIcon1.Visible=true;
this.ShowInTaskbar = true;
this.notifyIcon1.Visible = false;
}
// this.notifyIcon1.Visible = false;这句去掉
作者: Tsapi 发布时间: 2011-12-07
前面已经设置为true了,为什么又设置成false
作者: mizuho_2006 发布时间: 2011-12-07
▪ 云计算IDC服务都包括什么?▪ IT部门如何成为云服务提供商?▪ 云计算能让商业交易变得更透明...▪ 相对于公共PaaS,私人PaaS有哪...▪ 云计算能否简化企业项目管理?C# code
using System;
using System.Resources;
using System.Collections.Generic;
using System.ComponentModel;……
这个也是不行的。。你帮我写个示例吧。。
就是当程序运行时,托盘处无图标,任务栏有图标;
当程序最小化时,托盘处有图标,任务栏没有图标。
作者: ds2009w 发布时间: 2011-12-07
if (this.WindowState==FormWindowState.Minimized)
{
this.notifyIcon1.Visible=true;
this.ShowInTaskbar = true;
this.notifyIcon1.Visib……
我的想法是这样的:
当程序运行时,托盘处无图标,任务栏有图标;
当程序最小化时,托盘处有图标,任务栏没有图标。
作者: ds2009w 发布时间: 2011-12-07
private void Form1_SizeChanged(object sender, EventArgs e) { if (this.IsDisposed || this.WindowState == FormWindowState.Minimized) { this.ShowInTaskbar = false; this.notifyIcon1.Visible = true; } else { this.ShowIcon = true; this.notifyIcon1.Visible = false; } }
作者: DENQH 发布时间: 2011-12-07
private void Form1_SizeChanged(object sender, EventArgs e) { if (this.IsDisposed || this.WindowState == FormWindowState.Minimized) { this.ShowInTaskbar = false; this.notifyIcon1.Visible = true; } else { this.ShowInTaskbar = true; this.notifyIcon1.Visible = false; } }
作者: DENQH 发布时间: 2011-12-07
private void Form1_Load(object sender, EventArgs e)
{
notifyIcon1.Visible = false;
}
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (this.WindowState == FormWindowState.Normal)
{
this.notifyIcon1.Visible = true;
this.ShowInTaskbar = false;
this.Hide();
this.WindowState = FormWindowState.Minimized;
}
}
private void Form1_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.ShowInTaskbar = false ;
this.notifyIcon1.Visible = true;
}
}
}
作者: Tsapi 发布时间: 2011-12-07
C# code
private void Form1_SizeChanged(object sender, EventArgs e)
{
if (this.IsDisposed || this.WindowState == FormWindowState.Minimized)
{
this.Sh……
可不可以把你的整个窗体代码贴一下呢
作者: ds2009w 发布时间: 2011-12-07
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28