Exemple #1
0
 private void notifyBalloon(string title, string text, Int32 flags)
 {
     // Based on information found at http://www.thecodeproject.com/csharp/notifyballoon.asp
     // Has no effect on Windows 98 (and probably other) systems, even though it should.
     PInvoke.NotifyIconData uNIF = new PInvoke.NotifyIconData();
     uNIF.hwnd = ((NativeWindow)trayIcon.GetType().GetField("window", System.Reflection.BindingFlags.Instance |
                                                            System.Reflection.BindingFlags.NonPublic).GetValue(trayIcon)).Handle;
     uNIF.uID = (int)trayIcon.GetType().GetField("id", System.Reflection.BindingFlags.Instance |
                                                 System.Reflection.BindingFlags.NonPublic).GetValue(trayIcon);
     uNIF.dwStateMask      = 0; uNIF.hIcon = IntPtr.Zero; uNIF.szTip = "";
     uNIF.uCallbackMessage = IntPtr.Zero; uNIF.dwState = PInvoke.NIS_SHAREDICON;
     uNIF.uTimeout         = 11200; uNIF.dwInfoFlags = flags;
     uNIF.szInfoTitle      = title;
     uNIF.szInfo           = text;
     uNIF.uFlags           = PInvoke.NIF_INFO;
     uNIF.cbSize           = Marshal.SizeOf(uNIF);
     try
     {
         PInvoke.Shell_NotifyIconA(PInvoke.NIM_MODIFY, ref uNIF);
     }
     catch
     {
     }
 }