CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  .NET技术 >  C#

托盘问题,谢谢各位大虾。。。

楼主wwwqiang()2005-02-04 08:33:48 在 .NET技术 / C# 提问

小弟刚从DELPHI转过来,学C#不久,听介绍C#有个专门做托盘的控件,偶找了一些资料,可能是俺太笨,不得要解,希望那位大虾帮帮小弟,做个DEMO给小弟。谢谢!  
  E_mail:zdq801104@tom.com 问题点数:80、回复次数:7Top

1 楼yangxd_yi(杨一)回复于 2005-02-04 08:42:07 得分 40

看看这篇文章,对你应该有帮助,  
  http://www.vchome.net/dotnet/dotnetdocs/dotnet39.htm  
  帮你顶一下...Top

2 楼xzhy80(算了吧,散了吧)回复于 2005-02-04 08:50:29 得分 5

upTop

3 楼FJGoodGood(_FJ_强中强)回复于 2005-02-04 08:55:30 得分 20

给你个我作的例子:  
   
  using   System;  
  using   System.Drawing;  
  using   System.Collections;  
  using   System.ComponentModel;  
  using   System.Windows.Forms;  
  using   System.Data;  
   
  namespace   test  
  {  
  ///   <summary>  
  ///   Form1   的摘要说明。  
  ///   </summary>  
  public   class   Form1   :   System.Windows.Forms.Form  
  {  
  private   System.Windows.Forms.Button   button1;  
  private   System.Windows.Forms.NotifyIcon   notifyIcon1;  
  private   System.Windows.Forms.ContextMenu   contextMenu1;  
  private   System.Windows.Forms.MenuItem   menuItem1;  
  private   System.ComponentModel.IContainer   components;  
   
  public   Form1()  
  {  
  //  
  //   Windows   窗体设计器支持所必需的  
  //  
  InitializeComponent();  
   
  //  
  //   TODO:   在   InitializeComponent   调用后添加任何构造函数代码  
  //  
  }  
   
  ///   <summary>  
  ///   清理所有正在使用的资源。  
  ///   </summary>  
  protected   override   void   Dispose(   bool   disposing   )  
  {  
  if(   disposing   )  
  {  
  if   (components   !=   null)    
  {  
  components.Dispose();  
  }  
  }  
  base.Dispose(   disposing   );  
  }  
   
  #region   Windows   窗体设计器生成的代码  
  ///   <summary>  
  ///   设计器支持所需的方法   -   不要使用代码编辑器修改  
  ///   此方法的内容。  
  ///   </summary>  
  private   void   InitializeComponent()  
  {  
  this.components   =   new   System.ComponentModel.Container();  
  System.Resources.ResourceManager   resources   =   new   System.Resources.ResourceManager(typeof(Form1));  
  this.button1   =   new   System.Windows.Forms.Button();  
  this.notifyIcon1   =   new   System.Windows.Forms.NotifyIcon(this.components);  
  this.contextMenu1   =   new   System.Windows.Forms.ContextMenu();  
  this.menuItem1   =   new   System.Windows.Forms.MenuItem();  
  this.SuspendLayout();  
  //    
  //   button1  
  //    
  this.button1.Location   =   new   System.Drawing.Point(40,   40);  
  this.button1.Name   =   "button1";  
  this.button1.TabIndex   =   0;  
  this.button1.Text   =   "点击我最小化";  
  this.button1.Click   +=   new   System.EventHandler(this.button1_Click);  
  //    
  //   notifyIcon1  
  //    
  this.notifyIcon1.ContextMenu   =   this.contextMenu1;  
  this.notifyIcon1.Icon   =   ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));  
  this.notifyIcon1.Text   =   "我的应用程序";  
  this.notifyIcon1.Click   +=   new   System.EventHandler(this.notifyIcon1_Click);  
  //    
  //   contextMenu1  
  //    
  this.contextMenu1.MenuItems.AddRange(new   System.Windows.Forms.MenuItem[]   {  
    this.menuItem1});  
  //    
  //   menuItem1  
  //    
  this.menuItem1.Index   =   0;  
  this.menuItem1.Text   =   "复原";  
  this.menuItem1.Click   +=   new   System.EventHandler(this.notifyIcon1_Click);  
  //    
  //   Form1  
  //    
  this.AutoScaleBaseSize   =   new   System.Drawing.Size(6,   14);  
  this.ClientSize   =   new   System.Drawing.Size(292,   269);  
  this.Controls.Add(this.button1);  
  this.Name   =   "Form1";  
  this.Text   =   "Form1";  
  this.Load   +=   new   System.EventHandler(this.Form1_Load);  
  this.VisibleChanged   +=   new   System.EventHandler(this.Form1_VisibleChanged);  
  this.ResumeLayout(false);  
   
  }  
  #endregion  
   
  ///   <summary>  
  ///   应用程序的主入口点。  
  ///   </summary>  
  [STAThread]  
  static   void   Main()    
  {  
  Application.Run(new   Form1());  
  }  
   
  private   void   button1_Click(object   sender,   System.EventArgs   e)  
  {  
  this.WindowState   =   FormWindowState.Minimized;  
  this.Hide();  
  }  
   
  private   void   Form1_VisibleChanged(object   sender,   System.EventArgs   e)  
  {  
  notifyIcon1.Visible   =   !this.Visible;   //   如果窗口显示,托盘托表就不显示,如果窗口隐藏,托盘图标就显示  
  }  
   
  private   void   notifyIcon1_Click(object   sender,   System.EventArgs   e)  
  {  
  this.Show();  
  this.WindowState   =   FormWindowState.Normal;  
  }  
   
  private   void   Form1_Load(object   sender,   System.EventArgs   e)  
  {  
   
  }  
  }  
  }  
  Top

4 楼lzoxl(落花人独立,微雨雁双飞)回复于 2005-02-04 08:56:28 得分 5

notifyicon控件Top

5 楼skytear()回复于 2005-02-04 08:57:29 得分 5

upTop

6 楼zdq801104(【☆这个杀手不太冷☆】)回复于 2005-02-04 08:58:54 得分 0

谢谢各位大虾,特别是yangxd_yi(杨一)     AND     FJGoodGood(_FJ_强中强)Top

7 楼hawk234(鹰)回复于 2005-02-04 09:03:04 得分 5

upTop

相关问题

  • 关于托盘的问题,请教各位
  • 托盘
  • 托盘???
  • 各位的托盘区都有些什么东西?(发完就去写程序)
  • 问一个托盘有关的问题,望各位高手解答!!
  • 请问各位大虾怎样才能隐藏指定的系统托盘图标。如腾讯QQ的托盘图标等。
  • 系统托盘
  • 托盘编程
  • 托盘问题
  • ”托盘“程序

关键词

  • c#
  • 代码
  • notifyicon
  • 托盘
  • contextmenu
  • 大虾
  • menuitem
  • 谢谢
  • 小弟
  • eventargs e

得分解答快速导航

  • 帖主:wwwqiang
  • yangxd_yi
  • xzhy80
  • FJGoodGood
  • lzoxl
  • skytear
  • hawk234

相关链接

  • CSDN .NET频道
  • .NET类图书
  • C#类图书
  • .NET类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo