博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C# WPF获取任务栏时间区域的Rectangle
阅读量:4565 次
发布时间:2019-06-08

本文共 1712 字,大约阅读时间需要 5 分钟。

[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("Shell_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;                    }

  

转载于:https://www.cnblogs.com/liulun/p/4997821.html

你可能感兴趣的文章
mysql 导出查询结果到文件
查看>>
Js参数值中含有单引号或双引号解决办法
查看>>
python5
查看>>
js转换/Date(........)/
查看>>
mysql中limit用法
查看>>
C#开源爬虫NCrawler源代码解读以及将其移植到python3.2(1)
查看>>
c++ std::thread + lambda 实现计时器
查看>>
NSRunLoop个人理解
查看>>
BZOJ_1031_[JSOI2007]_字符串加密_(后缀数组)
查看>>
[osg]osg窗口显示和单屏幕显示
查看>>
前端技术在线文档地址链接
查看>>
077_打印各种时间格式
查看>>
[LeetCode] 101. Symmetric Tree_ Easy tag: BFS
查看>>
前端基础之html
查看>>
.Net基础之3——运算符
查看>>
scrapy管道MySQL简记
查看>>
使用 jQuery Deferred 和 Promise 创建响应式应用程序
查看>>
Bzoj1013--Jsoi2008球形空间产生器
查看>>
报文格式【定长报文】
查看>>
RDLC报表钻取空白页问题
查看>>