Resizing Gui text.

Get help with using AutoHotkey and its commands and hotkeys
User avatar
Posts: 988
Joined: 29 Sep 2013, 22:18

Resizing Gui text.

09 May 2020, 20:02

I am trying to resize a text control so that it can accommodate a change of font and a change of content. Things aren't going very well. Here is my function for finding the size of the new text area:

Code: Select all

	Global NH, TH, TY
	static h, hh
	Gui, set:new, -dpiscale -caption
	Gui, set:margin, 0,0
	Gui, set:font, s%f%
	Gui, set:add, text, w%w% vh, %t%
	Guicontrolget, h, set:pos
	Gui, set:show, autosize
	msgbox, 4096, screen: %NH%, h: %hh%
	Gui, set:destroy
	TY := floor((NH - hh)/2)
	TH := hh
And here is the code to display the result:

Code: Select all


	FF := SetFont(quest,TW,NH)
	Gui, Game:font, s%FF%
	Guicontrol, Game:font, B
	Guicontrol, Game:, B, %quest%
	GuiControl, Game:movedraw, B, y%TY% h%TH%
	Guicontrol, Game:show, B
	msgbox, 4096, screen: %NH%, h: %th%
The two screenshots below show the result. For some reason the resized text is cut off at the bottom. The Gui that the text is resized on has -dpiscale set. Why is the text not displaying correctly? Thanks.
SetTexPos.png (53 KiB) Viewed 180 times
Display.png (47.4 KiB) Viewed 180 times
User avatar
Posts: 988
Joined: 29 Sep 2013, 22:18

Re: Resizing Gui text.

09 May 2020, 20:08

As soon as I posted this I saw my error. I' didn't specify the font to be used in SetTextPos. Once I did that the Display text displayed correctly.

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, Bing [Bot], Google [Bot], miracle, songdg and 33 guests