如何测量可用于文本的标题栏的宽度? [英] How can I measure the width of the caption bar available for text?

查看:35
本文介绍了如何测量可用于文本的标题栏的宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试调整主窗口的标题以显示尽可能多的文件名以适合标题区域.所以,我想计算这里用红色矩形标记的区域的宽度:

I'm trying to adjust the caption of my main window to show as much of a file name as is possible to fit in the caption area. So, I'm looking to calculate the width of the area marked up here in the red rectangle:

现在,我希望代码可以使用任何可用的系统指标,从而避免被可能存在的所有各种平台/主题/dpi 变化所吸引.

Now, I would ideally like to have code that can use whatever system metrics are available and thereby avoid being caught out by all the various platform/theme/dpi variations that can exist.

如果真的有可能,这怎么可能?

How can this be done, if indeed it is even possible?

推荐答案

正如 andlabs评论WM_GETTITLEBARINFOEX 消息可用于获取所需信息.

As andlabs said in the comments, the WM_GETTITLEBARINFOEX message can be used to obtain the required information.

此消息可以发送到窗口和TITLEBARINFOEX 结构填充了标题栏及其每个按钮的状态和位置.从那里确定有多少空间可用于标题是一项简单的任务.

This message can be sent to the window and the TITLEBARINFOEX struct is populated with the state and location of the titlebar and each of its buttons. From there it is a simple task to determine how much space is available for the caption.

这篇关于如何测量可用于文本的标题栏的宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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