首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >获得TaskBar的精确位置和大小

获得TaskBar的精确位置和大小
EN

Stack Overflow用户
提问于 2015-03-29 14:37:24
回答 1查看 996关注 0票数 0

如何在Windows应用程序中准确地获得TaskBar的大小(高度)和位置?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-03-29 17:33:47

如下所示:

代码语言:javascript
复制
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

[DllImport("user32.dll", SetLastError = true)]
static extern bool GetWindowRect(IntPtr hwnd, out RECT lpRect);

[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
    public int Left;        // x position of upper-left corner
    public int Top;         // y position of upper-left corner
    public int Right;       // x position of lower-right corner
    public int Bottom;      // y position of lower-right corner
}

如何获取taskbar的位置和大小

代码语言:javascript
复制
//Get the handle of the task bar
IntPtr TaskBarHandle;
TaskBarHandle = FindWindow("Shell_traywnd", "");

RECT rct;

//Get the taskbar window rect in screen coordinates
GetWindowRect(TaskBarHandle, out rct);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29330440

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档