Jump to content

measuring how long input text is?


Recommended Posts

the label gets cut off if i make it to long

heres what im doing:

$datalabel = GUICtrlRead($input)
$leng = _MeasureString($datalabel, $Arial, 12)
$newlabel = GUICtrlCreateLabel($datalabel, 24, 470, $leng, 20)
GUISetState(-1, $GUI_ONTOP)
GUICtrlSetState($newlabel, $GUI_SHOW)

now im not sure if the font is arial 12 because i didnt specify it. its just the font that comes when you type into any regular input. my input i think is 100 by 20 if that'll make any difference...

Link to comment
Share on other sites

default font size for Autoit gui/controls will be 8.5

Also if your using the measure string function I wrote then the way you have it it's returning an array,

$leng = _MeasureString($datalabel, "Arial", 8.5)

$leng[0] = Width of the string

$leng[1] = Height of the string

you can return just the width or height

$leng = _MeasureString($datalabel, "Arial", 8.5, -1, -1, -1, 0)

$leng = Width of the string

$leng = _MeasureString($datalabel, "Arial", 8.5, -1, -1, -1, 1)

$leng = Height of the string

Edited by smashly
Link to comment
Share on other sites

ok, i changed my code to 8.5 like this:

$datalabel = GUICtrlRead($input)
$leng = _MeasureString($datalabel, $Arial, 8.5)
$newlabel = GUICtrlCreateLabel($datalabel, 24, 470, $leng, 20)
GUISetState(-1, $GUI_ONTOP)
GUICtrlSetState($newlabel, $GUI_SHOW)

but it still didnt change anything. the label text is still getting cut off...

Link to comment
Share on other sites

Look up and read my edited post..

The way your using the measurestring function it's returning an array

$leng = _MeasureString($datalabel, $Arial, 8.5)

$newlabel = GUICtrlCreateLabel($datalabel, 24, 470, $leng[0], 20)

Edited by smashly
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...