Exemplo n.º 1
0
        public static void Show(string title, string text, NotifyIcon notifyIcon)
        {
            try
            {
                if (title.Length > 60)
                {
                    title = title.Substring(0, 58) + " ...";
                }

                if (text.Length > 250)
                {
                    text = text.Substring(0, 248) + " ...";
                }

                Shell32.NOTIFYICONDATA notifyIconData = new Shell32.NOTIFYICONDATA();

                notifyIconData.cbSize = Marshal.SizeOf(typeof(Shell32.NOTIFYICONDATA));
                notifyIconData.hwnd = GetNotifyIconHandle(notifyIcon);
                notifyIconData.uID = GetNotifyIconID(notifyIcon);
                notifyIconData.uFlags = Shell32.NIF_INFO;
                notifyIconData.uTimeout = 3000;
                notifyIconData.dwInfoFlags = Shell32.NIIF_NONE | Shell32.NIIF_NOSOUND;
                notifyIconData.szInfoTitle = title;
                notifyIconData.szInfo = text;

                Shell32.Shell_NotifyIcon(Shell32.NIM_MODIFY, ref notifyIconData);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                Debug.WriteLine(ex.StackTrace);
            }
        }
Exemplo n.º 2
0
        //
        // Public methods
        //

        #region public static void Show(string title, string text, NotifyIcon notifyIcon)
        public static void Show(string title, string text, NotifyIcon notifyIcon)
        {
            try
            {
                if (title.Length > 60)
                {
                    title = title.Substring(0, 58) + " ...";
                }

                if (text.Length > 250)
                {
                    text = text.Substring(0, 248) + " ...";
                }

                Shell32.NOTIFYICONDATA notifyIconData = new Shell32.NOTIFYICONDATA();

                notifyIconData.cbSize      = Marshal.SizeOf(typeof(Shell32.NOTIFYICONDATA));
                notifyIconData.hwnd        = GetNotifyIconHandle(notifyIcon);
                notifyIconData.uID         = GetNotifyIconID(notifyIcon);
                notifyIconData.uFlags      = Shell32.NIF_INFO;
                notifyIconData.uTimeout    = 3000;
                notifyIconData.dwInfoFlags = Shell32.NIIF_NONE | Shell32.NIIF_NOSOUND;
                notifyIconData.szInfoTitle = title;
                notifyIconData.szInfo      = text;

                Shell32.Shell_NotifyIcon(Shell32.NIM_MODIFY, ref notifyIconData);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                Debug.WriteLine(ex.StackTrace);
            }
        }