网站公告列表

  没有公告

加入收藏
设为首页
联系站长
您现在的位置: 网络学院 >> 程序设计 >> VC编程 >> 文章正文
  如何自动移去系统托盘失效的图标            【字体:
如何自动移去系统托盘失效的图标
作者:佚名    文章来源:不详    点击数:    更新时间:2007-8-1    
正在装载数据……

  有些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);
}

站内文章搜索 高级搜索
文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
     directx 图形接口指南(…
     win2k下的api函数的拦截
     用crypto  api  实现公钥…
     根据别人的md5源码封装的…
     vc中使用gdi+合并jpg图片
     document/view的交互 --…
     windows下的函数hook技术
     windows api函数大全一
     用vc 6.0实现串行通信的…
     vc++技术内幕(第四版)…
  • 初学者,你应当如何学习C++以…

  • 如何在C#中使用Win32和其他库…

  • 如何实现那种流行的平面按钮

  • 如何用VB实现Modbus串行通讯

  • [VB][测试技术应用]VB与IE交…

  • CxGrid ,自动行号

  • Delphi如何从非主窗体启动

  • 如何取得LPT端口打印机支持的…

  • 自动化测试框架: Delphi中包…

  • 如何使用回车键模仿Tab键

  •   网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    网络学院©2007 www.23book.net
    为您提供web编程,vb编程,vc编程,服务器架设管理,数据库设计等方面的知识 站长:David