using Microsoft.Windows.Sdk; using System; using System.Runtime.InteropServices; namespace TheXamlGuy.NotificationFlyout.Common.Helpers { public partial class TaskbarHelper { private const string ShellTrayHandleName = "Shell_TrayWnd"; private const int SPI_SETWORKAREA = 0x002F; private readonly uint WM_TASKBARCREATED = PInvoke.RegisterWindowMessage("TaskbarCreated"); private enum AppBarEdge : uint { Left = 0, Top = 1, Right = 2, Bottom = 3 } private enum AppBarMessage : uint { New = 0x00000000, Remove = 0x00000001, QueryPos = 0x00000002, SetPos = 0x00000003, GetState = 0x00000004, GetTaskbarPos = 0x00000005, Activate = 0x00000006, GetAutoHideBar = 0x00000007, SetAutoHideBar = 0x00000008, WindowPosChanged = 0x00000009, SetState = 0x0000000A, } [DllImport("user32.dll", SetLastError = true)] private static extern IntPtr DefWindowProcW(IntPtr handle, uint msg, IntPtr wParam, IntPtr lParam); private static IntPtr GetSystemTrayHandle() => WindowHelper.GetHandle(ShellTrayHandleName); [DllImport("shell32.dll", SetLastError = true)] private static extern IntPtr SHAppBarMessage(AppBarMessage dwMessage, ref AppBarData pData); [StructLayout(LayoutKind.Sequential)] private struct AppBarData { public uint cbSize; public IntPtr hWnd; public uint uCallbackMessage; public AppBarEdge uEdge; public RECT rect; public int lParam; } } }