/// <summary> /// Initializes a new instance of the <see cref="TaskbarHook"/> class. /// </summary> /// <param name="messageBus">The message bus.</param> public TaskbarHook(IMessageBus messageBus) { _messageBus = messageBus; _callback = HookCallback; _taskBarHwnd = NativeMethods.FindWindow("Shell_TrayWnd", null); var taskbarHwndThreadId = NativeMethods.GetWindowThreadProcessId(_taskBarHwnd, IntPtr.Zero); _hook = NativeMethods.SetWindowsHookEx(WHCallWndProc, _callback, IntPtr.Zero, taskbarHwndThreadId); if (_hook == IntPtr.Zero) { Logger.Error("Unable to set windows hook"); } }
/// <summary> /// Initializes a new instance of the <see cref="AudioBandControl"/> class. /// </summary> public AudioBandControl() { SetStyle(ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true); UpdateDpi(GetDpi()); // Hook the window proc of the taskbar to listen to WM_DPICHANGED events _callback = HookCallback; _taskBarHwnd = NativeMethods.FindWindow("Shell_TrayWnd", null); var taskbarHwndThreadId = NativeMethods.GetWindowThreadProcessId(_taskBarHwnd, IntPtr.Zero); _hook = NativeMethods.SetWindowsHookEx(WHCallWndProc, _callback, IntPtr.Zero, taskbarHwndThreadId); if (_hook == IntPtr.Zero) { Logger.Error("Unable to set windows hook"); } }