[C#]如何让窗口最小化到系统托盘(右下角的小图标)??? 如何让窗口最小化到系统托盘(右下角的小图标)??? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个很简单,在一个事件中设置: this.Visible = false; this.ShowInTaskbar = false;即可. 有个NotifyIcon组件,所见即所得。 private void Form1_SizeChanged(object sender, System.EventArgs e) {NotifyIcon组件 if(this.WindowState==System.Windows.Forms.FormWindowState.Minimized) { this.Hide(); this.notifyIcon1.Visible=true; } }private void notifyIcon1_Click(object sender, System.EventArgs e) { if(this.WindowState==System.Windows.Forms.FormWindowState.Minimized) { this.Visible=true; this.WindowState=System.Windows.Forms.FormWindowState.Normal; this.notifyIcon1.Visible=false; } } 关闭程序:this.Close();或Application.Exit(); 呵呵~~基本看明白。。主要是this那些让我糊涂了 C#编写最小化时隐藏为任务栏图标的Window appllication. 1.设置窗体属性showinTask=false2.加notifyicon控件notifyIcon1,为控件notifyIcon1的属性Icon添加一个icon图标。3.添加窗体最小化事件(首先需要添加事件引用):// this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);//上面一行是主窗体InitializeComponent()方法中需要添加的引用private void Form1_SizeChanged(object sender, EventArgs e){if (this.WindowState==FormWindowState.Minimized){this.Hide();this.notifyIcon1.Visible=true;}}4.添加点击图标事件(首先需要添加事件引用):private void notifyIcon1_Click(object sender, EventArgs e){this.Visible = true;this.WindowState = FormWindowState.Normal;this.notifyIcon1.Visible = false;}5.可以给notifyIcon添加右键菜单:主窗体中拖入一个ContextMenu控件contextMenu1,点中控件,在上下文菜单中添加菜单,notifyIcon1的ContextMenu行为中选中contextMenu1作为上下文菜单。(可以在子菜单中添加行为) vb.net里面是meC# 里面是 this http://www.google.com/custom?domains=www.aspxboy.com&q=托盘&sa=%CB%D1%CB%F7&sitesearch=www.aspxboy.com&client=pub-0893236326612531&forid=1&ie=GB2312&oe=GB2312&cof=GALT%3A%230066CC%3BGL%3A1%3BDIV%3A%23999999%3BVLC%3A336633%3BAH%3Acenter%3BBGC%3AFFFFFF%3BLBGC%3AFF9900%3BALC%3A0066CC%3BLC%3A0066CC%3BT%3A000000%3BGFNT%3A666666%3BGIMP%3A666666%3BFORID%3A1%3B&hl=zh-CN 最小化到托盘 caizhenfang(边缘人) 已经给了如果要实现关闭的时候最小化挂Form的Closing事件private void Form_Closing(object sender, CancelEventArgs e){ e.Cancel = true; //取消关闭 this.WindowState = FormWindowState.Minimized;//设置为最小化} caizhenfang(边缘人) 的方法甚好! 帮楼主顶一顶! private void Form1_SizeChanged(object sender, System.EventArgs e) { if(this.WindowState == FormWindowState.Minimized) { this.Visible = false; this.notifyIcon1.Visible = true; } } private void notifyIcon1_Click(object sender, System.EventArgs e) { this.Visible = true; this.WindowState = FormWindowState.Normal; this.notifyIcon1.Visible = false; } http://www.aspxboy.com/private/showthread.asp?threadid=376 protected override void OnClosing(CancelEventArgs e) //重载关闭事件,使得按X是最小化 { HideTaskIco(); e.Cancel=true; } http://blog.csdn.net/chengking/archive/2005/11/06/524162.aspx中第四个软件实现了. 可以下载看一下. NotifyIcon组件,然后加个菜单,关联。 this.Hide();为 NotifyIcon 控件配置一个 ContextMenu,至少给出一个菜单项,用于点击事件操作,此事件中写上:this.WindowState = WindowState.Normal 添加noifyicon控件。点击窗体的最小化时,窗体.visible = false 。notifyicon.visible = true;点击notifyicon 时,窗体.visible = true,notifyicon = false 为什么139邮箱没有发送成功! 超级菜的问题C#比较大小。。 请问在C#里如何才能实现双击控件后变大,再双击后控件恢复原始大小? 关于 com中的 .tlb 未将对象引用设置到对象的实例的问题。 如何使用Visual C#.NET来调用操作系统Outlook Express发送邮件? 两个dataGridView做主从表数据联动效果,在主表的什么事件中写代码? .NET程序运行时内存飙升 读取文件为什么会使乱码? c#中编码 usc2转ansi 一句话就可解决的小问题,顺便散分 有关api的使用。如何在c#中使用GetVolumeInformation(),?
this.ShowInTaskbar = false;
即可.
{
NotifyIcon组件
if(this.WindowState==System.Windows.Forms.FormWindowState.Minimized)
{
this.Hide();
this.notifyIcon1.Visible=true;
}
}private void notifyIcon1_Click(object sender, System.EventArgs e)
{
if(this.WindowState==System.Windows.Forms.FormWindowState.Minimized)
{
this.Visible=true;
this.WindowState=System.Windows.Forms.FormWindowState.Normal;
this.notifyIcon1.Visible=false;
}
}
基本看明白。。主要是this那些让我糊涂了
1.设置窗体属性showinTask=false2.加notifyicon控件notifyIcon1,为控件notifyIcon1的属性Icon添加一个icon图标。3.添加窗体最小化事件(首先需要添加事件引用):// this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);//上面一行是主窗体InitializeComponent()方法中需要添加的引用private void Form1_SizeChanged(object sender, EventArgs e)
{
if (this.WindowState==FormWindowState.Minimized)
{
this.Hide();
this.notifyIcon1.Visible=true;
}}
4.添加点击图标事件(首先需要添加事件引用):private void notifyIcon1_Click(object sender, EventArgs e)
{
this.Visible = true;this.WindowState = FormWindowState.Normal;this.notifyIcon1.Visible = false;
}5.可以给notifyIcon添加右键菜单:主窗体中拖入一个ContextMenu控件contextMenu1,点中控件,在上下文菜单中添加菜单,notifyIcon1的ContextMenu行为中选中contextMenu1作为上下文菜单。(可以在子菜单中添加行为)
C# 里面是 this
{
e.Cancel = true; //取消关闭
this.WindowState = FormWindowState.Minimized;//设置为最小化
}
{
if(this.WindowState == FormWindowState.Minimized)
{
this.Visible = false;
this.notifyIcon1.Visible = true;
}
} private void notifyIcon1_Click(object sender, System.EventArgs e)
{
this.Visible = true;
this.WindowState = FormWindowState.Normal;
this.notifyIcon1.Visible = false;
}
{
HideTaskIco();
e.Cancel=true;
}
中第四个软件实现了. 可以下载看一下.
this.WindowState = WindowState.Normal
点击notifyicon 时,窗体.visible = true,notifyicon = false