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); }
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; } }
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); }
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"); } }