确定TMenuItem中文本的高度,以决定通过TMenuItem.OnMeasureItem更改菜单项的高度 [英] Determine Height of text in TMenuItem to decide to what height to change the MenuItem via TMenuItem.OnMeasureItem

查看:79
本文介绍了确定TMenuItem中文本的高度,以决定通过TMenuItem.OnMeasureItem更改菜单项的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Borland C ++ Builder 2009,当使用大字体时,MainMenu和Popup中的菜单项彼此太近,即使太大,文本也会在顶部和底部被切掉。

I use Borland C++ Builder 2009 and when a large font is used, the Menu items in MainMenu and Popup are too close to each other, text cut off on top and bottom even, when too big.

我知道我可以使用 TMenuItem.OnMeasureItem 更改项目的高度,但是我应该将其设置为什么高度?

I understand I can change the height of the items with TMenuItem.OnMeasureItem but to what height should I set it ?

计算理想高度的最佳方法是什么?如何获取理想高度(例如文本的高度)?

What's the best way to calculate an ideal height and how do I get the variables for it (e.g. height of text)?

推荐答案

OnMeasureItem 处理程序建议您在 Height var参数中使用默认值。

OnMeasureItem handlers suggests you default value in Height var parameter.

您可以将此值乘以当前屏幕PPI与默认PPI的比率,以获取100%的字体大小(96),例如高度:=天花板(高度*屏幕.PixelsPerInch / 96);

You can multiply this value by ratio of current screen PPI and default PPI for font size 100% (96), e.g. Height := Ceil(Height * Screen.PixelsPerInch / 96);

这篇关于确定TMenuItem中文本的高度,以决定通过TMenuItem.OnMeasureItem更改菜单项的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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