winform程序最小化系统托盘之后,C#怎么获取鼠标的单击事件和右键菜单 winform程序最小化系统托盘之后,C#怎么获取鼠标的单击事件和右键菜单我放了个contextMenu控件 还加了上下文菜单什么效果都没不知道应该加什么事件如何捕捉鼠标的单击事件和右键菜单 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在你的NotifyIcon控件的属性里设置,ContextMenuStrip属性,事件也是在此控件的事件里设置 改用contextMenuStrip菜单,并notifyIcon1.contextMenuStrip设置为contextMenuStrip1托盘里右键显示菜单: private void notifyIcon1_MouseClick(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Right) { contextMenuStrip1.Show() } } 先将窗体的Text属性设置为"动画系统图标示例",MaximiseBox、MinimiseBox、ShowInTaskbar属性均设置为False。 再往窗体上添加NotifyIcon控件、ContextMenu控件各一个。 将NotifyIcon控件的Icon属性设置为一个图标文件,Name属性设置为“m_trayIcon”;ContextMenu属性设置为"contextMenu1";接下来开始编辑ContextMenu控件现在我们开始编写代码部分:private bool m_bFlag;private bool m_bShowWnd; 修改Form1()函数为: public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // m_bFlag=true; m_bShowWnd=true; } private void menuItem1_Click(object sender, System.EventArgs e) { Application.Exit();//退出应用程序 } private void m_trayIcon_Click(object sender, System.EventArgs e) { if(m_bShowWnd == true)//隐藏主界面 { this.Visible = false; m_bShowWnd = false; } else//显示主界面 { this.Visible = true; m_bShowWnd = true; } } private void notifyIcon1_MouseClick(object sender, MouseEventArgs e) { if (e.Button == Right) { contextMenuStrip1.Show() } } DreamweaverCS5的安装 WinForm ATL + TAB 切换应用程序 窗体丢失焦点的问题 学习c#,大家都看哪些书 请教一个关于通过反射获取对象句柄的问题? 散分 100 并 询问这样的开发框架有没有价值 如何获取combobox的内容 对数据进行加密、解密 ASP.net里面怎么获得组件信息! binding数据,更新第一个字符时 table.GetChanges()==null的问题 窗体背景图片显示比例问题 一个关于Dictionary比较的问题,, 初学者问题
private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Right)
{
contextMenuStrip1.Show()
}
}
再往窗体上添加NotifyIcon控件、ContextMenu控件各一个。
将NotifyIcon控件的Icon属性设置为一个图标文件,Name属性设置为“m_trayIcon”;ContextMenu属性设置为"contextMenu1";接下来开始编辑ContextMenu控件现在我们开始编写代码部分:
private bool m_bFlag;
private bool m_bShowWnd;
修改Form1()函数为:
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
m_bFlag=true;
m_bShowWnd=true;
} private void menuItem1_Click(object sender, System.EventArgs e)
{
Application.Exit();//退出应用程序
} private void m_trayIcon_Click(object sender, System.EventArgs e)
{
if(m_bShowWnd == true)//隐藏主界面
{
this.Visible = false;
m_bShowWnd = false;
}
else//显示主界面
{
this.Visible = true;
m_bShowWnd = true;
}
}
{
if (e.Button == Right)
{
contextMenuStrip1.Show()
}
}