Can you send a signal to Windows Explorer to make it refresh the systray icons?

前端 未结 8 806
执笔经年
执笔经年 2020-12-03 00:22

This problem has been afflicting me for quite a while and it\'s been really annoying.

Every time I login after a reboot/power cycle the explorer takes some time to s

8条回答
  •  暖寄归人
    2020-12-03 00:44

    After lots of times trying I found that there are three issues you must to know:

    • The parent of hidden tray window is NotifyIconOverflowWindow, other than Shell_TrayWnd.
    • You shouldn't use caption parameter of FindWindowEx to find a window, because these is lots of langue versions of Windows OS, they are not always be the same title Obviously.
    • Use spy++ of Visual Studio to find or make assurance what you want.

    So, I changed code from @Stephen Klancher and @Louis Davis, thank you guys.

    The following code worked for me.

    #define FW(x,y) FindWindowEx(x, NULL, y, L"")
    void RefreshTaskbarNotificationArea()
    {
        HWND hNotificationArea;
        RECT r;
        GetClientRect(hNotificationArea = FindWindowEx(FW(NULL, L"NotifyIconOverflowWindow"), NULL, L"ToolbarWindow32", NULL), &r);
        for (LONG x = 0; x < r.right; x += 5)
        {
            for (LONG y = 0; y < r.bottom; y += 5)
            {
                SendMessage(hNotificationArea, WM_MOUSEMOVE, 0, (y << 16) + x);
            }
        }
    }
    

提交回复
热议问题