Пример #1
0
        private static void RedrawWindowsSystemTrayArea()
        {
            try
            {
                // Windows XP and earlier
                IntPtr hNotificationArea = Native.FindWindowEx
                                           (
                    Native.FW(Native.FW(Native.FW(IntPtr.Zero, "Shell_TrayWnd"), "TrayNotifyWnd"), "SysPager"),
                    IntPtr.Zero,
                    "ToolbarWindow32",
                    "Notification Area"
                                           );

                // Windows Vista and later
                if ((hNotificationArea == IntPtr.Zero) || (hNotificationArea.ToInt32() == Native.INVALID_HANDLE_VALUE))
                {
                    hNotificationArea = Native.FindWindowEx
                                        (
                        Native.FW(Native.FW(Native.FW(IntPtr.Zero, "Shell_TrayWnd"), "TrayNotifyWnd"), "SysPager"),
                        IntPtr.Zero,
                        "ToolbarWindow32",
                        "User Promoted Notification Area"
                                        );
                }

                if ((hNotificationArea == IntPtr.Zero) || (hNotificationArea.ToInt32() == Native.INVALID_HANDLE_VALUE))
                {
                    return;
                }

                // Get the notification bounds
                Native.Rect rect = new Native.Rect();
                Native.GetClientRect(hNotificationArea, ref rect);

                // Wiggle the mouse over the notification area
                // Note: this doesn't actually move the mouse cursor on the screen -- this just sends a message to the system tray window
                //       that mouse movement occurred over it, forcing it to refresh.  Sending messages asking for a repaint or invalidated
                //       area don't work, but this does.
                for (UInt32 x = 0; x < rect.Right; x += 5)
                {
                    for (UInt32 y = 0; y < rect.Bottom; y += 5)
                    {
                        Native.SendMessage(hNotificationArea, Native.WM_MOUSEMOVE, 0, (y << 16) | x);
                    }
                }
            }
            catch { }
        }
Пример #2
0
 public static IntPtr FW(IntPtr hwndParent, string lpszClass)
 {
     return(Native.FindWindowEx(hwndParent, IntPtr.Zero, lpszClass, string.Empty));
 }