How do I dynamically resize text in an edit box

317 Views Asked by At

In Autohotkey, I have an edit that is a particular size. I would like to resize the text so that it displays in the visible area of the edit rather than wrapping it and having to scroll down.

Initially I was going to use StrLen("String") function, but that won't help as different characters will affect when the text wraps

String := "This string of text exceeds the visible... area"
font_size = 18
Gui, +AlwaysOnTop
Gui, Font, S%font_size%
Gui, Add, Edit, gText_Size vFr_Text X10 -Border center r2 W270, % String
Gui, Show
return

Text_Size:
;Find out if the text exceeds visible area
;if so Change font size
return
1

There are 1 best solutions below

2
Xiddoc On

You can use the +Limit Option to limit the text to the visible space. You can add it to your code like so:

Gui, Add, Edit, gText_Size vFr_Text X10 -Border center r2 W270 +Limit, % String