示例#1
0
 private void Create(uint id)
 {
     NotifyIconEx.NotifyIconData mHandle = new NotifyIconEx.NotifyIconData();
     mHandle.cbSize           = (uint)Marshal.SizeOf(mHandle);
     this.m_handle            = NotifyIconEx.m_messageSink.Handle;
     mHandle.hWnd             = this.m_handle;
     this.m_id                = id;
     mHandle.uID              = this.m_id;
     mHandle.uCallbackMessage = 0x400;
     mHandle.uFlags           = mHandle.uFlags | NotifyIconEx.NotifyFlags.Message;
     mHandle.hIcon            = this.m_icon.Handle;
     mHandle.uFlags           = mHandle.uFlags | NotifyIconEx.NotifyFlags.Icon;
     mHandle.szTip            = this.m_text;
     mHandle.uFlags           = mHandle.uFlags | NotifyIconEx.NotifyFlags.Tip;
     if (!this.m_visible)
     {
         mHandle.dwState = NotifyIconEx.NotifyState.Hidden;
     }
     mHandle.dwStateMask = mHandle.dwStateMask | NotifyIconEx.NotifyState.Hidden;
     NotifyIconEx.Shell_NotifyIcon(NotifyIconEx.NotifyCommand.Add, ref mHandle);
     NotifyIconEx.m_messageSink.ClickNotify        += new NotifyIconEx.NotifyIconTarget.NotifyIconHandler(this.OnClick);
     NotifyIconEx.m_messageSink.DoubleClickNotify  += new NotifyIconEx.NotifyIconTarget.NotifyIconHandler(this.OnDoubleClick);
     NotifyIconEx.m_messageSink.RightClickNotify   += new NotifyIconEx.NotifyIconTarget.NotifyIconHandler(this.OnRightClick);
     NotifyIconEx.m_messageSink.ClickBalloonNotify += new NotifyIconEx.NotifyIconTarget.NotifyIconHandler(this.OnClickBalloon);
     NotifyIconEx.m_messageSink.TaskbarCreated     += new EventHandler(this.OnTaskbarCreated);
 }
示例#2
0
 public void Remove()
 {
     if (this.m_id != 0)
     {
         NotifyIconEx.NotifyIconData mHandle = new NotifyIconEx.NotifyIconData();
         mHandle.cbSize = (uint)Marshal.SizeOf(mHandle);
         mHandle.hWnd   = this.m_handle;
         mHandle.uID    = this.m_id;
         NotifyIconEx.Shell_NotifyIcon(NotifyIconEx.NotifyCommand.Delete, ref mHandle);
         this.m_id = 0;
     }
 }
示例#3
0
 private void OnRightClick(object sender, uint id)
 {
     if (id == this.m_id && this.m_contextMenu != null)
     {
         NotifyIconEx.POINT pOINT = new NotifyIconEx.POINT();
         NotifyIconEx.GetCursorPos(ref pOINT);
         NotifyIconEx.SetForegroundWindow(NotifyIconEx.m_messageSink.Handle);
         object[] empty = new object[1];
         empty[0] = EventArgs.Empty;
         this.m_contextMenu.GetType().InvokeMember("OnPopup", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, this.m_contextMenu, empty);
         NotifyIconEx.TrackPopupMenuEx(this.m_contextMenu.Handle, 64, pOINT.x, pOINT.y, NotifyIconEx.m_messageSink.Handle, IntPtr.Zero);
     }
 }
示例#4
0
 private void Update()
 {
     NotifyIconEx.NotifyIconData handle = new NotifyIconEx.NotifyIconData();
     handle.cbSize = (uint)Marshal.SizeOf(handle);
     handle.hWnd   = NotifyIconEx.m_messageSink.Handle;
     handle.uID    = this.m_id;
     handle.hIcon  = this.m_icon.Handle;
     handle.uFlags = handle.uFlags | NotifyIconEx.NotifyFlags.Icon;
     handle.szTip  = this.m_text;
     handle.uFlags = handle.uFlags | NotifyIconEx.NotifyFlags.Tip;
     handle.uFlags = handle.uFlags | NotifyIconEx.NotifyFlags.State;
     if (!this.m_visible)
     {
         handle.dwState = NotifyIconEx.NotifyState.Hidden;
     }
     handle.dwStateMask = handle.dwStateMask | NotifyIconEx.NotifyState.Hidden;
     NotifyIconEx.Shell_NotifyIcon(NotifyIconEx.NotifyCommand.Modify, ref handle);
 }
示例#5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            log _log = new log();

            _log.write("---------------------程序启动----------------------");
            this.NotifyIcon               = new NotifyIconEx();
            this.NotifyIcon.Text          = "无线精灵2016";
            this.NotifyIcon.Icon          = base.Icon;
            this.NotifyIcon.Visible       = false;
            this.NotifyIcon.ContextMenu   = this.contextMenu1;
            this.NotifyIcon.Click        += new EventHandler(this.OnClickIcon);
            this.NotifyIcon.DoubleClick  += new EventHandler(this.notifyIcon1_DoubleClick);
            this.NotifyIcon.BalloonClick += new EventHandler(this.OnClickBalloon);
            BackgroundWorker backgroundWorker = new BackgroundWorker();

            backgroundWorker.DoWork += new DoWorkEventHandler(this.BW_DoWork);
            backgroundWorker.RunWorkerAsync();
        }
示例#6
0
 public void ShowBalloon(string title, string text, NotifyIconEx.NotifyInfoFlags type, int timeoutInMilliSeconds)
 {
     if (timeoutInMilliSeconds >= 0)
     {
         NotifyIconEx.NotifyIconData handle = new NotifyIconEx.NotifyIconData();
         handle.cbSize            = (uint)Marshal.SizeOf(handle);
         handle.hWnd              = NotifyIconEx.m_messageSink.Handle;
         handle.uID               = this.m_id;
         handle.uFlags            = NotifyIconEx.NotifyFlags.Info;
         handle.uTimeoutOrVersion = (uint)timeoutInMilliSeconds;
         handle.szInfoTitle       = title;
         handle.szInfo            = text;
         handle.dwInfoFlags       = type;
         NotifyIconEx.Shell_NotifyIcon(NotifyIconEx.NotifyCommand.Modify, ref handle);
         return;
     }
     else
     {
         throw new ArgumentException("The parameter must be positive", "timeoutInMilliseconds");
     }
 }