如何自动移去系统托盘失效的图标

H沉默的羔羊w

H沉默的羔羊w

2016-02-19 14:05

图老师小编精心整理的如何自动移去系统托盘失效的图标希望大家喜欢,觉得好的亲们记得收藏起来哦!您的支持就是小编更新的动力~

  有些Window应用程序在启动以后会在系统托盘去添加一个小图标, 一般情况下当程序正常退出时会自动去掉,但有时由于应用程序非法关闭,这个图标便一直留在托盘区,直到用鼠标移动图标上时,才会自己消失.那么我们就可以模拟鼠标移动到逐个图标上,来达到这个效果.
  void __fastcall RemoveDeadIcons()
  {
      HWND hTrayWindow;
      RECT rctTrayIcon;
      int nIconWidth;
      int nIconHeight;
      TPoint CursorPos;
      int nRow;
      int nCol;
  
      // Get tray window handle and bounding rectangle
      hTrayWindow = FindWindowEx(FindWindow(
              "Shell_TrayWnd", NULL), 0, "TrayNotifyWnd", NULL);
      if(!GetWindowRect(hTrayWindow, &rctTrayIcon))
          return;
      // Get small icon metrics
      nIconWidth = GetSystemMetrics(SM_CXSMICON);
      nIconHeight = GetSystemMetrics(SM_CYSMICON);
      // Save current mouse position }
      GetCursorPos(&CursorPos);
      // Sweep the mouse cursor over each icon in the tray in both dimensions
      for(nRow=0; nRow(rctTrayIcon.bottom-rctTrayIcon.top)/nIconHeight; nRow++)
      {
          for(nCol=0; nCol(rctTrayIcon.right-rctTrayIcon.left)/nIconWidth; nCol++)
          {
              SetCursorPos(rctTrayIcon.left + nCol * nIconWidth + 5,
                      rctTrayIcon.top + nRow * nIconHeight + 5);
              Sleep(0);
          }
      }
      // Restore mouse position
      SetCursorPos(CursorPos.x, CursorPos.x);
      // Redraw tray window (to fix bug in multi-line tray area)
      RedrawWindow(hTrayWindow, NULL, 0, RDW_INVALIDATE  RDW_ERASE  RDW_UPDATENOW);
  
   }
展开更多 50%)
分享

猜你喜欢

如何自动移去系统托盘失效的图标

编程语言 网络编程
如何自动移去系统托盘失效的图标

实用技巧:清除系统托盘图标

windows 操作系统
实用技巧:清除系统托盘图标

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

搜狗浏览器2018怎样将图标放置系统托盘中?

浏览器
搜狗浏览器2018怎样将图标放置系统托盘中?

让MSN图标在Windows7系统托盘处显示的秘诀

电脑入门
让MSN图标在Windows7系统托盘处显示的秘诀

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

基于java开发之系统托盘的应用

编程语言 网络编程
基于java开发之系统托盘的应用

利用Visual C++实现系统托盘程序

编程语言 网络编程
利用Visual C++实现系统托盘程序

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

使用CommaText

使用CommaText

vba语句select case End Select

vba语句select case End Select
下拉加载更多内容 ↓