scrollbar for multiline label

Hi there… I have a multiline label which dynamically changes depending what tool the user hovers over.
Because of the discrepancies between varying monitor sizes, this label sometime gets chopped off before the end of the text is reached.

My question…
Is there a way to find out if the label text exceeds the height of the label box?
If I can find this, I could show a scrollbar to view all the text. Is there a piece of code for this?
Has anybody used anything similar? I know that a text area control automatically has a scroll bar - but it’s ugly and plus, I want the background to show through the text.

off the top of my head

function getStringHeight(ta as TextArea) as Integer
dim g as graphics
g.font=ta.font
g.fontsize=ta.fontsize
return g.stringheight(ta.text,ta.width)
end function

function toobig(ta as TextArea) as boolean
return getStringHeight(ta)>ta.height
end function

like I said. off the top of my head, so you may have to check the lang ref to tweak it a bit

Sorry - I should have made this clear - it’s for a multiline label… I want the background to be transparent… I tried to create a scrolling canvas with the picture being drawn, the text and transparent=1. It looks horrible.
Best result would be with a multiline label that I could scroll if the text was bigger than the label size. If the text fits, the scroll bar would be invisible

Why not remove the border of the TextArea and set its BackColor to the same as the window?

ok… and how does what I posted not help you with that?

[quote=291926:@Sean Clancy]Is there a way to find out if the label text exceeds the height of the label box?
If I can find this, I could show a scrollbar to view all the text. Is there a piece of code for this?[/quote]

Dave gave you a way to estimate the eight of the text.

There are two other possible strategies : using Dave’s code, when you see the text reaching the maximum size, simply reduce the point size, or use a narrow character, such as Arial Narrow.

The other way is to place a much larger label on a ContainerControl, together with a Scrollbar. That will enable you to scroll the label. You can even mix with Dave’s method to see when the text overflows, and display the scrollbar only then.

Note that a multiline label does not naturally scroll, so unless you delete the superior part of the text, adding a scrollbar alone would not suffice.

Now it’s on you to get to work :wink:

I get an error on lines:

[quote]g.font=ta.font
g.fontsize=ta.fontsize
[/quote]
That ta has no member named font or font size.

Docs say it should be TextFont and TextSize.
Copying and pasting code from the forum is not recommended. It’s a good way to share ideas, but there’s no code-checker.

Thanks Tim!