C # WPF Gets the rectangle of the taskbar time zone

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.