各位网友帮我看看,使用NotifyIcon组件,为什么没在通知区域显示图标?

gengpengfei2012 2012-04-30 12:02:07
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace NotifyIconExample
{
public partial class Form1 : Form
{
private bool isExit = false;
public Form1()
{
InitializeComponent();
notifyIcon1.ContextMenuStrip = this.contextMenuStrip1;
notifyIcon1.Visible = true;
notifyIcon1.BalloonTipText = "aaaaaaaa";
notifyIcon1.DoubleClick+=new System.EventHandler(this.notifyIcon1_DoubleClick);
this.ShowInTaskbar=false;
this.WindowState=FormWindowState.Minimized;
this.SetDesktopLocation(
Screen.PrimaryScreen.WorkingArea.Width-this.Width-20,
Screen.PrimaryScreen.WorkingArea.Height-this.Height-50);
}

private void notifyIcon1_DoubleClick(object sender, EventArgs e)
{
if(this.WindowState==FormWindowState.Minimized)
{
this.WindowState=FormWindowState.Normal;
this.Activate();
}
else
{
this.WindowState=FormWindowState.Minimized;
}
}

private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
isExit=true;
this.Close();
}

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if(isExit==false)
{
this.WindowState=FormWindowState.Minimized;
e.Cancel=true;
}
}
}
}
用的是Microsoft visual stadio 2010
...全文
132 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
scjypzh 2012-04-30
  • 打赏
  • 举报
回复
NotifyIcon控件设置Icon属性了么?
gengpengfei2012 2012-04-30
  • 打赏
  • 举报
回复
在form1 窗口中用到了两个控件NotifyIcon 和 contextMenuStrip, 但是运行后任务栏同时区域没显示图标,看了看代码没问题, 这是什么情况?
zhujiawei7 2012-04-30
  • 打赏
  • 举报
回复
notifyIcon1不设置ICON小图标 托盘中就不会显示
rayyu1989 2012-04-30
  • 打赏
  • 举报
回复
+1[Quote=引用 5 楼 的回复:]

引用 4 楼 的回复:
没有设置

要设置ICON才能显示的
[/Quote]
SQL777 2012-04-30
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 的回复:]
没有设置
[/Quote]
要设置ICON才能显示的
gengpengfei2012 2012-04-30
  • 打赏
  • 举报
回复
没有设置

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧