-->

Determine Height of text in TMenuItem to decide to

2019-08-03 17:58发布

问题:

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.

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)?

回答1:

OnMeasureItem handlers suggests you default value in Height var parameter.

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);