How to change text border later?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
m3user
Posts: 235
Joined: 17 Jan 2014, 18:11

How to change text border later?

02 Dec 2019, 11:50

Is it possible to change the text control border after the control is created? The code below doesn't seem to work.

Code: Select all

gui, add, text, w100 h30 vMyText, Text
guicontrol, +border, MyText
gui, show
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: How to change text border later?

02 Dec 2019, 12:48

i tested it for picture control and it failed too

teadrinker
Posts: 4330
Joined: 29 Mar 2015, 09:41
Contact:

Re: How to change text border later?

02 Dec 2019, 12:55

Code: Select all

WS_BORDER := 0x00800000
gui, add, text, w100 h30 hwndhText, Text
Gui, Add, Pic, Icon45 hwndhPic, Shell32.dll
Gui, Add, Button, gSetBorders, Set Borders
gui, show
Return

SetBorders:
   WinSet, Style, +%WS_BORDER%, ahk_id %hText%
   WinSet, Style, +%WS_BORDER%, ahk_id %hPic%
   Return
m3user
Posts: 235
Joined: 17 Jan 2014, 18:11

Re: How to change text border later?

02 Dec 2019, 14:11

Thank you very much!
Just one more question: I have many controls, each has unique hwnd (like Control1, Control2 etc.). I need to change just the border of the n-th control. How should I specify ahk_id for the control n (Variable)? Thanks.
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: How to change text border later?

02 Dec 2019, 14:21

seems like an oversight/bug/wishlist item for GuiControl

teadrinker
Posts: 4330
Joined: 29 Mar 2015, 09:41
Contact:

Re: How to change text border later?

02 Dec 2019, 15:38

Yeah, seems like that.
m3user wrote: How should I specify ahk_id for the control n (Variable)?

Code: Select all

WS_BORDER := 0x00800000
gui, add, text, w100 h30 hwndhCtrl1, Text
Gui, Add, Pic, Icon45 hwndhCtrl2, Shell32.dll

n := 1
WinSet, Style, +%WS_BORDER%, % "ahk_id" hCtrl%n%
gui, show
Return
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: How to change text border later?

02 Dec 2019, 15:50

teadrinker wrote:
02 Dec 2019, 15:38
Yeah, seems like that.
maybe not after all:

docs:
Border: Provides a thin-line border around the control. Most controls do not need this because they already have a type-specific border. When adding a border to an existing control, it might be necessary to increase the control's width and height by 1 pixel.
this works:

Code: Select all

gui, add, text, w100 h30 vMyText, Text
guicontrol, +border, MyText
guicontrol, Move, MyText, w101 h31
gui, show
with help from google:
https://autohotkey.com/board/topic/149734-border-to-a-picture-via-guicontrol/

not sure why guicontrol requires increasing the size of the control, when WinSet can apply the style without doing that..

teadrinker
Posts: 4330
Joined: 29 Mar 2015, 09:41
Contact:

Re: How to change text border later?

02 Dec 2019, 16:05

When using WinSet the size does not change:

Code: Select all

WS_BORDER := 0x00800000
Gui, Add, Text, w100 h50 hwndhText
Gui, Add, Text, x+1 yp wp hp
WinSet, Style, +%WS_BORDER%, ahk_id %hText%
GuiControl, +border, Static2
GuiControl, Move, Static2, w101 h51
Gui, Show
m3user
Posts: 235
Joined: 17 Jan 2014, 18:11

Re: How to change text border later?

02 Dec 2019, 17:44

Thanks Teadrinker. :)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: inseption86, mikeyww and 424 guests