# Set AdvPanel.Caption depending on Caption Fontsize

Hi,

during the creation of an advanced panel, I set the font and size of the caption so it does fit.

During runtime, the font gets resized, but the height of the caption area stays the same, hence the caption heading bleeds into the content area.

In other parts of my application, I use the function Canvas.TextHeight(), but I have no idea how I could use it with the AdvPanel since there is no access to the canvas.

Any suggestion on how I could set the height of the caption based on the utilized caption font, either in code or via the properties?

Thanks,
Thomas

Note: Delphi 11 fully patched, AdvPanel v2.6.1.0 on 4k monitor with 3840x2160, 175% scaling

Hi,

I properly wasn't clear enough. Setting the height of the caption is only half of the answer. The other one is to what should I set the height, or in other words, how can I figure out the height any given caption text is occupying?

As I wrote in my original post, if the canvas is accessible the Canvas.TextHeight(...) function can be used to get text metrics needed.

I have not found a way to get the needed text height. Any help, pointers for a workaround, or a general technique on how to do this would be greatly appreciated.

Thanks,
Thomas

There is at this moment no such built-in function.
We added it now and in the next update it will be available as public function GetCaptionSize: TSize

Hello Bruno,

thank you so much for this info. Like always great service from you and your team.

``````advPanel1.Caption.Background.Canvas.Font := advPanel1.Caption.Font;