@joshatt
I was playing around with this last night, perhaps it will help.
It shows two approaches to get to the same outcome.
I'll take a look at your new code later today.
Example 1:
Code: Select all
#SingleInstance, Force
MyText := "I'm still learning, and I begin to realize giving it a width is a better way, especially when there're other controls down below. But on learning purpose, sometimes this text control could be at right side of other control, and I want a good alignment at the right window edge, or, I may want an auto adjusting text control if the window is resizable."
Gui, 1:+AlwaysOnTop +Resize +HwndGui1Hwnd -Caption
Gui, 1:Margin, % M := 10 , 10
Gui, 1:Font, s10 , Arial
Gui, 1:Add, Edit, xm ym w250 r1 +hwndEdit1hwnd ,
Gui, 1:Add, Text, xm y+10 w250 +hwndText1hwnd +Border , % MyText
Gui, 1:Show, Hide , example 1
DetectHiddenWindows, On
WinGetPos,,, w, h, % "ahk_id " Gui1Hwnd
DetectHiddenWindows, Off
Gui, 1:+Caption
Gui, 1:Show,, example 1
Gui, % "1: +MinSize" w " +MaxSize750x" h - 16
return
GuiCLose:
*ESC::ExitApp
GuiSize:
if( !ft && ft := !ft )
return
WinGetPos,,, w, h, % "ahk_id " Gui1Hwnd
GuiControl, 1:MoveDraw , % Edit1Hwnd , % " w" ( w - ( M * 2 ) - 15 )
Gui, FakeGui:Font, s10 , Arial
Gui, FakeGui:Add, Text, % " w" ( w - ( M * 2 ) - 15 ) , % MyText
GuiControlGet, pos, FakeGui:pos , Static1
Gui, FakeGui:Destroy
GuiControl, 1:MoveDraw , % Text1Hwnd , % " w" posW " h" posH
if( lw != w || lh != h )
SetTimer, ShowGui, -100
lh := h , lw := w
sleep, 30
return
ShowGui:
if( !GetKeyState( "LButton" ) ){
ft := 0
Gui, 1:Show, AutoSize NA
}else
SetTimer, ShowGui, -100
return
Example 2:
Code: Select all
#SingleInstance, Force
MyText := "I'm still learning, and I begin to realize giving it a width is a better way, especially when there're other controls down below. But on learning purpose, sometimes this text control could be at right side of other control, and I want a good alignment at the right window edge, or, I may want an auto adjusting text control if the window is resizable."
Gui, 1:+AlwaysOnTop +Resize +MaxSize750 +MinSize250 +HwndGui1Hwnd +ToolWindow
Gui, 1:Margin, % M := 10 , 10
Gui, 1:Font, s10 , Arial
Gui, 1:Add, Edit, xm ym w250 r1 +hwndEdit1hwnd ,
Gui, 1:Add, Text, xm y+10 w250 +hwndText1hwnd +Border , % MyText
Gui, 1:Show,, example 2
return
GuiCLose:
*ESC::ExitApp
GuiSize:
if( !ft && ft := !ft )
return
if( GetKeyState( "LButton" ) ){
SetTimer, GuiSize, -100
Sleep, 60
return
}
WinGetPos,,, w, h, % "ahk_id " Gui1Hwnd
GuiControl, 1:MoveDraw , % Edit1Hwnd , % " w" ( w - ( M * 2 ) - 15 )
Gui, FakeGui:Font, s10 , Arial
Gui, FakeGui:Add, Text, % " w" ( w - ( M * 2 ) - 15 ) , % MyText
GuiControlGet, pos, FakeGui:pos , Static1
Gui, FakeGui:Destroy
GuiControl, 1:MoveDraw , % Text1Hwnd , % " w" posW " h" posH
Gui, 1:Show, AutoSize NA
return