设一个定时器,在OnTimer中改变系统托盘的图标。

解决方案 »

  1.   

    使用NOTIFYICONDATA结构生成托盘图标,使用Shell_NotifyIcon函数响应NIM_MODIFY
    消息修改图标
      

  2.   

    定义CXXX成员:
    NOTIFYICONDATA nid
    CXXX::OnCreate()
    {
       for (int i=0;i<nCount;i++) 
          m_hIcon[i]=AfxGetApp()->LoadIcon(...);
       初始nid
       ...
       nid.hIcon = m_hIcon[0];
       Shell_NotifyIcon(NIM_ADD,&nid);
       ...
       SetTimer(...);
       ...
    }
    CXXX::OnTimer(...)
    {
      static int s_nIndex = 0;
      if (...)
      {
         nid.hIcon = m_hIcon[s_nIndex]; 
         可修改nid.szTip;
         Shell_NotifyIcon(NIM_MODIFY,&nid);
         s_nIndex++;
         s_nIndex %= nCount;
       }
         ...}CXXX::OnDestroy()
    {
         Shell_NotifyIcon(NIM_DELETE ,&nid);
         ...
    }