zoukankan      html  css  js  c++  java
  • WPF窗体最小化到任务栏

    WPF程序也可以很轻松的实现类似QQ那样最小化到任务栏的功能。

            WindowState ws;
            WindowState wsl;
            NotifyIcon notifyIcon;
    
    
            #region Constructions
            public MainWindow()
            {
               
                InitializeComponent();//显示托盘。
                icon();
                //保证窗体显示在上方。
                wsl = WindowState;
            }
            #endregion
    
            private void icon()
            {
                this.notifyIcon = new NotifyIcon();
                this.notifyIcon.BalloonTipText = "Hello, 文件监视器"; //设置程序启动时显示的文本
                this.notifyIcon.Text = "文件监视器";//最小化到托盘时,鼠标点击时显示的文本
                this.notifyIcon.Icon = new System.Drawing.Icon("Downloads.ico");//程序图标
                this.notifyIcon.Visible = true;
                notifyIcon.MouseDoubleClick += OnNotifyIconDoubleClick;
                this.notifyIcon.ShowBalloonTip(1000);
            }
    
            private void OnNotifyIconDoubleClick(object sender, EventArgs e)
            {
                this.Show();
                WindowState = wsl;
            }
    
            private void Window_StateChanged(object sender, EventArgs e)
            {
                ws = WindowState;
                if (ws == WindowState.Minimized)
                {
                    this.Hide();
                }
            }
  • 相关阅读:
    3年度研发项目情况项目目标文档
    2系统利益相关者描述案例
    讨论结果
    本学期《软件需求分析》需要掌握的内容(个人总结)
    第二周进度条
    四则运算
    第一周进度记录
    java web
    ke tang zuo ye
    2015-05-26 随笔
  • 原文地址:https://www.cnblogs.com/Gyoung/p/2805932.html
Copyright © 2011-2022 走看看