Help with Font Height in Textbox

BlitzMax Forums/MaxGUI Module/Help with Font Height in Textbox

Scaremonger(Posted 2015) [#1]
Hi,

I have a test application that logs results to a Textbox but I'm having problems calculating how many lines I can display in the textbox before the scrollbar appears.

The code below posts events to the Textbox and works fine until it's resized; Basically I need to find a way to recalculate the value in SCROLL:Int ...



TextHeight doesn't work in MaxGui.

Any suggestions?


Chalky(Posted 2015) [#2]
Extremely crude method which works:



...but assumes the font is 13 pixels high. Maybe someone with good API knowledge could suggest a better/proper solution.


Scaremonger(Posted 2015) [#3]
@Chalky: That's what I'm doing at the moment. Thanks.

Is it possible to use the scrollbars auto-appearance to flag the need to reduce the number of lines?


Chalky(Posted 2015) [#4]
The code below posts events to the Textbox and works fine until it's resized; Basically I need to find a way to recalculate the value in SCROLL:Int ...

The code I posted above does what I thought you were asking for - recalculates SCROLL when the window is resized so that your code correctly adjusts lines[] to fit in the client area of your window.

[edit] Ah - I get it - the scrollbars still appear once the window is smaller than the maximum line length. Hmmm - gimme a mo...


Chalky(Posted 2015) [#5]
I think this is close to what you want (assuming I've understood you correctly!):



...but still not perfect. Unfortunately the scrollbars still pop up momentarily (I've disabled them, which reduces the visual ugliness a bit) during a window resize - and sometimes (seemingly at random) stubbornly refuse to hide if the window is made very small (which *seems* to have been eliminated by using SetMinWindowSize).


Henri(Posted 2015) [#6]
Hi,

single line height in text control consists of font height, font extent and line spacing (which might vary), so in order to calculate max lines accurately you would need to know 2 things:

1. Client height of textarea
2. Difference between two lines

Second might be calculated using TextAreaCharY.

PS. This is just an idea. No testing was involved :-)

-Henri