已阅读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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- NO2-MIL-101-Cr-Diaquafluorotris-μ-2-nitro-1-4-benzenedicarboxylato-2-κO1-κO-1-μ3-oxotrichromium-生命科学试剂-MCE
- N1-N3-N5-Tri-pyridin-3-yl-benzene-1-3-5-tricarboxamide-生命科学试剂-MCE
- 高中生物实验动物细胞分裂实验现象观察训练试题及答案
- 初中英语口语英文自我介绍能力训练试题及答案
- 2026年打卤面师傅(技师)职业技能等级认定考前冲刺试题
- 广东省惠州市惠城区2026年九年级上学期语文期末试卷附答案
- 2026年湖南长沙市雨花区上学期期末质量检测试卷七年级英语
- 2026年河南周口市鹿邑县中考考前模拟B卷英语
- 2026年广西桂林市部分校初中学业水平考试模拟卷(二)英语
- 美容院产品客户消费绩效评估表
- 中远海运集团社招集中笔试试卷汇编2026
- 2026人教版生物八年级上册 第五单元 第一章 生态系统 单元测试一
- 巴西礼仪课件
- 雨课堂学堂在线《学术英语写作(北京交通)》学堂云单元测试考核答案
- 超声诊断学急诊应用
- 口腔修复学(中级356)《专业知识》真题及解析(2026年)
- ISO9001-2026质量管理体系中英文版标准条款全文
- DB11∕T 945.1-2023 建设工程施工现场安全防护、场容卫生及消防保卫标准 第1部分:通则
- it研发安全管理制度
- (高清版)DG∕TJ 08-207-2008 房屋修缮工程技术规程
- 23G409先张法预应力混凝土管桩
评论
0/150
提交评论