c#win系统托盘.doc_第1页
c#win系统托盘.doc_第2页
c#win系统托盘.doc_第3页
c#win系统托盘.doc_第4页
c#win系统托盘.doc_第5页
已阅读5页,还剩1页未读, 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

WINFORM 窗口最小化到系统托盘窗口最小化到系统托盘 C 编写最小化时隐藏为任务栏图标的 Window appllication 1 设置 WinForm 窗体属性 showinTask false 2 加 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 控件 NicontextMenu 点中控件 在上下文菜单中添 加菜单 notifyIcon1 的 ContextMenu 行为中选中 NicontextMenu 作为上下文菜单 this notifyIcon1 new System Windows Forms NotifyIcon ponents this NicontextMenu new System Windows Forms ContextMenu this menuItem Hide new System Windows Forms MenuItem this menuItem Show new System Windows Forms MenuItem this menuItem Aubot new System Windows Forms MenuItem this menuItem Exit new System Windows Forms MenuItem this notifyIcon1 ContextMenu this NicontextMenu this notifyIcon1 Icon System Drawing Icon resources GetObject NotifyIcon Icon this notifyIcon1 Text this notifyIcon1 Visible true this notifyIcon1 DoubleClick new System EventHandler this notifyIcon1 DoubleClick this notifyIcon1 Click new System EventHandler this notifyIcon1 Click this NicontextMenu MenuItems AddRange new System Windows Forms MenuItem this menuItem Hide this menuItem Show this menuItem Aubot this menuItem Exit menuItem Hide this menuItem Hide Index 0 this menuItem Hide Text 隐藏 this menuItem Hide Click new System EventHandler this menuItem Hide Click menuItem Show this menuItem Show Index 1 this menuItem Show Text 显示 this menuItem Show Click new System EventHandler this menuItem Show Click menuItem Aubot this menuItem Aubot Index 2 this menuItem Aubot Text 关于 this menuItem Aubot Click new System EventHandler this menuItem Aubot Click menuItem Exit this menuItem Exit Index 3 this menuItem Exit Text 退出 this menuItem Exit Click new System EventHandler this menuItem Exit Click protected override void OnClosing CancelEventArgs e this ShowInTaskbar false this WindowState FormWindowState Minimized e Cancel true protected override void OnClosing CancelEventArgs e this ShowInTaskbar false this WindowState FormWindowState Minimized e Cancel true private void CloseCtiServer timer Enabled false DJ160API DisableCard this NotifyIcon Visible false this Close this Dispose Application Exit private void HideCtiServer this Hide private void ShowCtiServer this Show this WindowState FormWindowState Normal this Activate private void CtiManiForm Closing object sender System ComponentModel CancelEventArgs e this CloseCtiServer private void menuItem Show Click object sender System EventArgs e this ShowCtiServer private void menuItem Aubot Click object sender System EventArgs e private void menuItem Exit Click object sender System EventArgs e this CloseCtiServer private void menuItem Hide Click object sender System EventArgs e this HideCtiServer private void CtiManiForm SizeChanged object sender System

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论