WinFrom 
C#
做了个系统托盘,想让系统托盘有个闪动的效果.就跟QQ的一样.传说是搞个定时器,然后不停更换ico图片.怎么更换系统托盘上的图标? 给我个示例代码吧        private void timer系统托盘_Tick(object sender, EventArgs e)
        {
            if (m闪动)
            {
                //ico1
                m闪动 = true;
            }
            else
            {
                //ico2
                m闪动 = false;
            }
        }

解决方案 »

  1.   

    我给你个建议,用gif文件做成动态效果,你可以先去下载一个动态的图片试试看行不行
    有消息来了就替换这个文件。
    没有消息就替换回静态图片
    不要用代码实现
      

  2.   


     我知道替换这回事,
    但是我不知道手写代码来替换,我那系统托盘上的图标用鼠标选上去的.怎么手写代码指定ico?
      

  3.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace WindowsApplication8
    {
        public partial class Form1 : Form
        {
            Icon icon1 = System.Drawing.Icon.ExtractAssociatedIcon(@"C:\Windows\notepad.exe");
            Icon icon2 = System.Drawing.Icon.ExtractAssociatedIcon(@"C:\Windows\regedit.exe");
            public Form1()
            {
                InitializeComponent();            this.notifyIcon1.Text = "test";
                this.Text = "test";
                this.timer1.Interval = 1000;
                this.timer1.Enabled = true;            this.Icon = icon1;
                this.notifyIcon1.Icon = this.Icon;
            }        bool tag = false;
            private void timer1_Tick(object sender, EventArgs e)
            {            this.Icon = tag ? icon2 : icon1;
                this.notifyIcon1.Icon = this.Icon;
                tag = !tag;
            }
        }
    }
      

  4.   

    notifyIcon1.Icon = @"C:\TestEnvironment\Test.gif";
    这个样子不行?
      

  5.   

    不用做GIF的,
    加个定时器,轮换显示图片:
    http://www.sz-accp.com.cn/xxyd/ShowArticle.asp?ArticleID=3036
    C#实现托盘动态图标
      

  6.   


    Application.StartupPath + "..\..\Test.gif";按照你机器上的环境改
      

  7.   


    notifyIcon1.Icon = @"C:\TestEnvironment\Test.gif"; 
    notifyIcon1.Icon = Application.StartupPath + "..\..\Test.gif"; //错误 14 无法将类型“string”隐式转换为“System.Drawing.Icon”
    这2个都用不了.报错了
      

  8.   

    不至于吧System.Drawing.Icon ico = new Icon("....")
      

  9.   

    你就有 jinjazz  的方法就成
      

  10.   


    GIF 不是ICO.....Bitmap _IconBmp =(Bitmap)Image.FromFile(@"C:\TestEnvironment\Test.gif");notifyIcon1.Icon = System.Drawing.Icon.FromHandle(_IconBmp.GetHicon());