/// <include file='doc\TrayIcon.uex' path='docs/doc[@for="NotifyIcon.WndProc"]/*' /> /// <devdoc> /// The NotifyIcon's window procedure. Inheriting classes can override this /// to add extra functionality, but should not forget to call /// base.wndProc(msg); to ensure the NotifyIcon continues to function properly. /// </devdoc> /// <internalonly/> private void WndProc(ref Message msg) { switch (msg.Msg) { case WM_TRAYMOUSEMESSAGE: switch ((int)msg.LParam) { case NativeMethods.WM_LBUTTONDBLCLK: WmMouseDown(ref msg, MouseButtons.Left, 2); break; case NativeMethods.WM_LBUTTONDOWN: WmMouseDown(ref msg, MouseButtons.Left, 1); break; case NativeMethods.WM_LBUTTONUP: WmMouseUp(ref msg, MouseButtons.Left); break; case NativeMethods.WM_MBUTTONDBLCLK: WmMouseDown(ref msg, MouseButtons.Middle, 2); break; case NativeMethods.WM_MBUTTONDOWN: WmMouseDown(ref msg, MouseButtons.Middle, 1); break; case NativeMethods.WM_MBUTTONUP: WmMouseUp(ref msg, MouseButtons.Middle); break; case NativeMethods.WM_MOUSEMOVE: WmMouseMove(ref msg); break; case NativeMethods.WM_RBUTTONDBLCLK: WmMouseDown(ref msg, MouseButtons.Right, 2); break; case NativeMethods.WM_RBUTTONDOWN: WmMouseDown(ref msg, MouseButtons.Right, 1); break; case NativeMethods.WM_RBUTTONUP: if (contextMenu != null) { ShowContextMenu(); } WmMouseUp(ref msg, MouseButtons.Right); break; } break; case NativeMethods.WM_COMMAND: if (IntPtr.Zero == msg.LParam) { if (Command.DispatchID((int)msg.WParam & 0xFFFF)) { return; } } else { window.DefWndProc(ref msg); } break; default: if (msg.Msg == WM_TASKBARCREATED) { WmTaskbarCreated(ref msg); } window.DefWndProc(ref msg); break; } }
private void WndProc(ref Message msg) { switch (msg.Msg) { case WM_TRAYMOUSEMESSAGE: switch ((int)msg.LParam) { case NativeMethods.WM_LBUTTONDBLCLK: WmMouseDown(ref msg, MouseButtons.Left, 2); break; case NativeMethods.WM_LBUTTONDOWN: WmMouseDown(ref msg, MouseButtons.Left, 1); break; case NativeMethods.WM_LBUTTONUP: WmMouseUp(ref msg, MouseButtons.Left); break; case NativeMethods.WM_MBUTTONDBLCLK: WmMouseDown(ref msg, MouseButtons.Middle, 2); break; case NativeMethods.WM_MBUTTONDOWN: WmMouseDown(ref msg, MouseButtons.Middle, 1); break; case NativeMethods.WM_MBUTTONUP: WmMouseUp(ref msg, MouseButtons.Middle); break; case NativeMethods.WM_MOUSEMOVE: WmMouseMove(ref msg); break; case NativeMethods.WM_RBUTTONDBLCLK: WmMouseDown(ref msg, MouseButtons.Right, 2); break; case NativeMethods.WM_RBUTTONDOWN: WmMouseDown(ref msg, MouseButtons.Right, 1); break; case NativeMethods.WM_RBUTTONUP: if (contextMenu != null || contextMenuStrip != null) { ShowContextMenu(); } WmMouseUp(ref msg, MouseButtons.Right); break; case NativeMethods.NIN_BALLOONSHOW: OnBalloonTipShown(); break; case NativeMethods.NIN_BALLOONHIDE: OnBalloonTipClosed(); break; case NativeMethods.NIN_BALLOONTIMEOUT: OnBalloonTipClosed(); break; case NativeMethods.NIN_BALLOONUSERCLICK: OnBalloonTipClicked(); break; } break; case NativeMethods.WM_COMMAND: if (IntPtr.Zero == msg.LParam) { if (Command.DispatchID((int)msg.WParam & 0xFFFF)) { return; } } else { window.DefWndProc(ref msg); } break; case NativeMethods.WM_DRAWITEM: // If the wparam is zero, then the message was sent by a menu. // See WM_DRAWITEM in MSDN. if (msg.WParam == IntPtr.Zero) { WmDrawItemMenuItem(ref msg); } break; case NativeMethods.WM_MEASUREITEM: // If the wparam is zero, then the message was sent by a menu. if (msg.WParam == IntPtr.Zero) { WmMeasureMenuItem(ref msg); } break; case NativeMethods.WM_INITMENUPOPUP: WmInitMenuPopup(ref msg); break; case NativeMethods.WM_DESTROY: // Remove the icon from the taskbar UpdateIcon(false); break; default: if (msg.Msg == WM_TASKBARCREATED) { WmTaskbarCreated(ref msg); } window.DefWndProc(ref msg); break; } }
private void WndProc(ref Message msg) { int num = msg.Msg; if (num <= 0x2c) { switch (num) { case 0x2b: if (msg.WParam == IntPtr.Zero) { this.WmDrawItemMenuItem(ref msg); } return; case 0x2c: if (msg.WParam == IntPtr.Zero) { this.WmMeasureMenuItem(ref msg); } return; case 2: this.UpdateIcon(false); return; } } else { switch (num) { case 0x111: if (IntPtr.Zero == msg.LParam) { if (Command.DispatchID(((int)msg.WParam) & 0xffff)) { return; } return; } this.window.DefWndProc(ref msg); return; case 0x117: this.WmInitMenuPopup(ref msg); return; default: if (num != 0x800) { break; } switch (((int)msg.LParam)) { case 0x200: this.WmMouseMove(ref msg); return; case 0x201: this.WmMouseDown(ref msg, MouseButtons.Left, 1); return; case 0x202: this.WmMouseUp(ref msg, MouseButtons.Left); return; case 0x203: this.WmMouseDown(ref msg, MouseButtons.Left, 2); return; case 0x204: this.WmMouseDown(ref msg, MouseButtons.Right, 1); return; case 0x205: if ((this.contextMenu != null) || (this.contextMenuStrip != null)) { this.ShowContextMenu(); } this.WmMouseUp(ref msg, MouseButtons.Right); return; case 0x206: this.WmMouseDown(ref msg, MouseButtons.Right, 2); return; case 0x207: this.WmMouseDown(ref msg, MouseButtons.Middle, 1); return; case 520: this.WmMouseUp(ref msg, MouseButtons.Middle); return; case 0x209: this.WmMouseDown(ref msg, MouseButtons.Middle, 2); return; case 0x402: this.OnBalloonTipShown(); return; case 0x403: this.OnBalloonTipClosed(); return; case 0x404: this.OnBalloonTipClosed(); return; case 0x405: this.OnBalloonTipClicked(); return; } return; } } if (msg.Msg == WM_TASKBARCREATED) { this.WmTaskbarCreated(ref msg); } this.window.DefWndProc(ref msg); }