如何获得一个WinForms窗体标题栏高度的大小? [英] How to get the size of a Winforms Form titlebar height?

查看:149
本文介绍了如何获得一个WinForms窗体标题栏高度的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,如果它是工具窗口或可最小化的形式,我希望能够以编程方式获取其高度。

So if it's toolwindow or a minimizable form, I want to be able to get its height programmatically.

这可能吗?如果是的话怎么样?

Is this possible? If so how?

推荐答案

您可以通过使用确定标题栏的高度为工具窗口和正常的形式:

You can determine titlebar height for both tool-windows and normal forms by using:

Rectangle screenRectangle=RectangleToScreen(this.ClientRectangle);

int titleHeight = screenRectangle.Top - this.Top;

在哪里'这'是你的表单。

Where 'this' is your form.

ClientRectangle返回窗体的客户区的边界。 RectangleToScreen将其转换为屏幕坐标是相同的坐标系作为窗体的屏幕位置。

ClientRectangle returns the bounds of the client area of your form. RectangleToScreen converts this to screen coordinates which is the same coordinate system as the Form screen location.

这篇关于如何获得一个WinForms窗体标题栏高度的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆