// Author: Gockner, Simon // Created: 2021-04-07 // Copyright(c) 2021 SimonG. All Rights Reserved. using System; using Lib.NotifyIcon.Windows.Native; using Lib.NotifyIcon.Windows.Native.Types; namespace Lib.NotifyIcon.Windows { /// /// A native Win32 helper window encapsulation for dealing with the window messages sent by the notification icon /// internal class NotifyIconHelperWindow : NativeWindow { private readonly NotifyIcon _notifyIcon; public NotifyIconHelperWindow(NotifyIcon notifyIcon) => _notifyIcon = notifyIcon; /// /// This function will receive all the system window messages relevant to our window. /// protected override IntPtr WndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam) { switch (msg) { case (uint) CustomWindowsMessage.WmTrayMouse: { // Forward WM_TRAYMOUSE messages to the tray icon's window procedure _notifyIcon.WndProc(hWnd, msg, wParam, lParam); break; } default: return base.WndProc(hWnd, msg, wParam, lParam); } return IntPtr.Zero; } } }