开发工具:
文件大小: 3kb
下载次数: 0
上传时间: 2009-09-20
详细说明: C#[托盘]Form.cs.txt public partial class Form2 : Form { // private System.ComponentModel.Container components = null; private Icon mNetTrayIcon = new Icon("Icon1.ico"); private NotifyIcon TrayIcon; private ContextMenu notifyiconMnu; public Form2() { InitializeComponent(); this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(320, 560); //this.ControlBox = false; //this.MaximizeBox = false; ///this.MinimizeBox = false; this.Name = "Form2"; this.ShowInTaskbar = false; this.Text = "用Visual C#做托盘程序!"; //this.WindowState = System.Windows.Forms.FormWindowState.Minimized; this.Load += new System.EventHandler(Form2_Load); this.ResumeLayout(false); //设定托盘程序的各个属性 TrayIcon = new NotifyIcon(); TrayIcon.Icon = mNetTrayIcon; TrayIcon.Text = "用Visual C#做托盘程序" + "\n" + "作者:马金虎于2001.12.08"; TrayIcon.Visible = true; TrayIcon.Click += new System.EventHandler(this.click); //定义一个MenuItem数组,并把此数组同时赋值给ContextMenu对象 MenuItem[] mnuItms = new MenuItem[3]; mnuItms[0] = new MenuItem(); mnuItms[0].Text = "C#做托盘程序!"; mnuItms[0].Click += new System.EventHandler(this.showmessage); mnuItms[1] = new MenuItem("-"); mnuItms[2] = new MenuItem(); mnuItms[2].Text = "退出"; mnuItms[2].Click += new System.EventHandler(this.ExitSelect); mnuItms[2].DefaultItem = true; notifyiconMnu = new ContextMenu(mnuItms); TrayIcon.ContextMenu = notifyiconMnu; //为托盘程序加入设定好的ContextMenu对象 } //托盘程序中的事件响应 public void click(object sender, System.EventArgs e) { if (this.WindowState == FormWindowState.Minimized) { this.WindowState = FormWindowState.Normal; } } public void showmessage(object sender, System.EventArgs e) { MessageBox.Show("你点击了菜单的第一个选项"); } public void ExitSelect(object sender, System.EventArgs e) { //隐藏托盘程序中的图标 TrayIcon.Visible = false; //关闭系统 this.Close(); } private void Form2_Load(object sender, EventArgs e) { } } QQ:292258449 ...展开收缩
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.