this is my first post here as I did not find any solution for following problem in v2 (which worked in v1):
I have a number (not known at the beginning!) of slider + text elements. Therefore I use a Loop to create those.
I assigned new variables "MySlider%index%" and "MyText%index%" to identify the controls and be able at the end to assign the value in slider to the text element below.
v1:
Code: Select all
shift_right = 3
n = 3
startValue = 12
width = 50
Gui, font, bold s14, Arial
Gui, add, text, section xm ym, Example
Gui, font
Loop, %n%
{
index := A_Index + startValue - 1
Gui, font, s12, Arial
Gui, add, groupbox, xs+%shift_right% ys+30 w58 h280 center, Chn-%index%
Gui, font, s12, Arial
Gui, add, slider, xp+9 yp+20 h270 range0-90 vertical center line1 page10 tickinterval10 AltSubmit vMySlider%index% gsliderFunc, 90
Gui, font, s14, Arial
Gui, add, text, xp-8 yp+275 r1 w%width% center vMyText%index%, 90
shift_right += 65
}
Gui, Submit
Gui, Show
return
GuiClose:
GuiEscape:
ExitApp
sliderFunc()
{
RegExMatch(A_GuiControl, "MySlider(\d+)", num)
GuiControlGet, %A_GuiControl%
valueNew := %A_GuiControl%
controlNew = MyText%num1%
GuiControl, ,%controlNew%, %valueNew%
}
In v2 some things can be done easier (e.g. MySlider%index% is not needed anymore, function call, ...), but one of the main points which I do not get to work is the assigment in line 19:
Code: Select all
MyText%index% := myGui.Add("Text", "xp-8 yp+275 r1 w" width " center", "90")
But as said I do not know at the beginning which would be "names" of these variables as "startValue" and "n" are normally derived from a config file and are "variable".
v2 (which will not work unless one uncomment line 5):
Code: Select all
shift_right := 3
width := 50
startValue := 12
n := 3
;global MyText12, MyText13, MyText14
myGui := Gui()
myGui.OnEvent("close",closeGui)
myGui.OnEvent("escape",closeGui)
myGui.SetFont("bold s14", "Arial")
myGui.Add("text", "section xm ym", "Example")
Loop n
{
index := A_Index + startValue - 1
myGui.SetFont("s10", "Arial")
myGui.Add("groupbox", "xs+" shift_right " ys+30 w58 h280 center", "Chn-" index)
myGui.Add("slider", "xp+9 yp+20 h270 range0-90 vertical center line1 page10 tickinterval10 AltSubmit", "90").OnEvent("change", sliderFunc.Bind(,,index))
myGui.SetFont("bold s12", "Arial")
MyText%index% := myGui.Add("Text", "xp-8 yp+275 r1 w" width " center", "90")
shift_right += 65
}
myGui.Submit()
myGui.Show()
closeGui(*) {
ExitApp
}
sliderFunc(obj, info, idx) {
MyText%idx%.Text := obj.Value
}
The only solution which came to my mind was to assign the Hwnd of the text element (which is an integer value) to an array (which I can specify).
But maybe there is another solution?
Best regards,
Michael