国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

如何自動移去系統托盤失效的圖標

2019-11-17 05:32:21
字體:
來源:轉載
供稿:網友

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

}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 桓台县| 怀来县| 绍兴县| 广安市| 彭水| 湖州市| 峨眉山市| 报价| 饶平县| 长沙市| 绥滨县| 平原县| 罗定市| 永福县| 崇仁县| 鸡西市| 宕昌县| 嘉黎县| 凤冈县| 湖南省| 乐山市| 长兴县| 黎川县| 南充市| 阜康市| 宝山区| 宁安市| 颍上县| 高唐县| 三明市| 耒阳市| 获嘉县| 方城县| 化隆| 塔城市| 县级市| 宜黄县| 寿宁县| 合江县| 江川县| 基隆市|