Source: C # WPF Gets the rectangle of the taskbar time zone
[StructLayout (layoutkind.sequential)] public struct Windowrect {public int left; public int top; public int right; public int bottom; } [DllImport ("User32.dll")] private static extern IntPtr FindWindow (string ClassName, string windowname); [DllImport ("User32.dll")] private static extern IntPtr FindWindowEx (IntPtr hwndparent, IntPtr Hwndchildafter, String className, String windowname); [DllImport ("User32.dll")] private static extern bool ShowWindow (IntPtr hWnd, int ncmdshow); [DllImport ("User32.dll")] static extern bool GetWindowRect (HandleRef hwnd, out windowrect rect); const int sw_hide = 0; const int sw_show = 5; [DllImport ("User32.dll")] static extern IntPtr SetParent (IntPtr hwndchild, IntPtr hwndnewparent); Public MainWindow () {InitializeComponent (); This. Loaded + = mainwindow_loaded; } private void Mainwindow_loaded (object sender, RoutedEventArgs e) {IntPtr Taskbarwnd = FindWindow ("She Ll_traywnd ", NULL); IntPtr tray = FindWindowEx (Taskbarwnd, IntPtr.Zero, "Traynotifywnd", null); IntPtr Trayclock = FindWindowEx (Tray, IntPtr.Zero, "Trayclockwclass", null); Windowrect rect; GetWindowRect (New HandleRef (Application.Current.MainWindow, Trayclock), out rect); This. Top = Rect.top; This. left = Rect.left; This. Width = Rect.right-left; This. Height = Rect.bottom-rect.top; This. topmost = true; }
C # WPF Gets the rectangle of the taskbar time zone