For my project I need 12 independent progress bars at the same Gui. For this purpose have written a function to initialize and an other function to update the bar.
This works perfectly in test environment as show in the code below .
WORKING:
Code: Select all
Gui, New, , Test Title
ProgressBarInit(1, 100, 200)
GUI Show, w500 h500
loop,
{
Sleep 50
ProgressBarUpdate(1, A_Index)
if A_index >110
Break
}
{ ;### Exit Handling
GuiEscape:
GuiClose:
ExitApp
}
[b]ProgressBarInit(n, x, y) [b]
{
; n: unique Number of Bar
; x,y: Start Coordinates
; PGx_[n] stores the x position in a global variable
Global
PGx_%n% := x
Gui Font, s6
GUI Add, Text, % " x" x + 104 " y" y - 15 " vt1_" n , % "Last"
GUIControl, Font, % " vt1_" n
GUI Add, Picture, % " x" x " y" y - 3 , pic\bar_Box.png
GUI Add, Picture, % " x" x + 101 " y" y - 6 , pic\bar100.ico
GUI Add, Picture, % " x" x + 1 " y" y - 2 " w1 vP1_" n , pic\bar.png
GUI Add, Picture, % " x" x + 1 " y" y - 2 " w1 vP2_" n , pic\bar_END.png
}
ProgressBarUpdate(n, v)
{
; n: unique Number of Bar as in Init
; value: Value 0..125
h := PGx_%n%
GuiControl,, % "P1_" n , *w%v% pic\bar.png
GuiControl, Move, % "P2_" n , % " *x" value + h " pic\bar_end.png"
GuiControl, % " vt2_" n , % v
}
"Duplicate function definition"
GUI.ahk
Code: Select all
{ ;### INIT
Y_Delta := 20
Top_Clear := 14
Gui, ABGui:New, HWNDGuiHwnd, Citect Backup Tool
Gui, %GuiHwnd%:Default
}
ProgressBarInit(1,100,600)
{ ;### Common Main Page stuff
GUI Font ,Bold ;Start of Bold Text
Gui Add, Text
, x10 y8 w200 h23 +0x200
, 1) Select User and Options
Gui Add, Text
, x10 y376 w400 h23 +0x200
, 2) Provide a Comment
GUI Font , ;End of Bold Text
}
{ ;### Comment Section
y := 400
Gui Add, GroupBox
, % "x15 y" y " w970 h80"
, Comment to Backup (User and Time will be added automativally, maximal 256 Chars)
Gui Add, Edit
, % "x25 y" y + 20 " w950 h24 Limit256 vvCommentTXT "
Gui Add, Button
, % "x25 y" y + 50 " w72 h24 vvSubmit gSubmit"
, Submit
Gui Add, Button
, % "x100 y" y + 50 " w72 h24 disabled vvReEdit gReEdit"
, Edit
}
{ ;### Main Action Buttons
Gui Add, Button
, % "x84 y720 w144 h48 vvEscape gGuiEscape"
, ESC
Gui Add, Button
, % "x312 y720 w144 h48 vvBackupOnly gBackupOnly"
, Backup Only
Gui Add, Button
, % "x540 y720 w144 h48 vvLastBackup gLastBackup"
, Distribute (last) Backup only
Gui Add, Button
, % "x768 y720 w144 h48 vvBackup GBackup"
, Backup and Distribute
;#### some more text
Gui Add, Text
, x540 y690 w141 h23 +0x200
, Last File:
Gui Add, Text
, x15 y773 w200 h23 +0x200
, V1.0 by Andreas Boettcher
}
{ ;### Tab View
Gui Add, Picture, % "x16 y34 vpic1 gpic1 " , pic\Main_Disabled.png
GuiControl, Hide, pic1
Gui Add, Picture, % "x58 y34 vpic2 gpic1 " , pic\Users_Disabled.png
GuiControl, Hide, pic2
Gui Add, Picture, % "x133 y34 vpic3 gpic1 " , pic\Locations_Disabled.png
GuiControl, Hide, pic3
Gui Add, Picture, % "x236 y34 vpic4 gpic1 " , pic\Names_Disabled.png
GuiControl, Hide, pic4
Gui Add, Tab3
, % "x15 y32 w970 h326 Choose" DisplayMode
, Main|Manage User|Manage Locations|Names + Formats
DisplayMode:= 1 ;select first tab again after any Editing had select other for reload
{ ;##Tab 1 Main
Gui Tab, 1
y_S := 62
y_Delta := 24
Gui Add, GroupBox, % "x28 y" y_S " w204 h286", Active User
for each, item in o_user {
y := Top_Clear + y_S + y_Delta * (A_Index -1)
If A_Index = 1
Gui Add, Radio
, % "x40 y" y " w160 h23 vRadioActiveUser ggRadio Checked"Item.IsLastActive
, % Item.short " - " Item.name
Else
Gui Add, Radio
, % "x40 y" Y " w160 h23 ggRadio Checked"Item.IsLastActive
, % Item.short " - " Item.name
}
Gui Add, GroupBox, % "x244 y" y_S " w726 h64", Backup
{
Gui Add, CheckBox
, % "x252 y" Top_Clear + Y_S " w132 h23 Checked"
, Create Backup
y := Top_Clear + y_S + Y_Delta
Gui Add, CheckBox
, % "x252 y" y " w134 h23 Checked"
, Copy to Users Machine
Gui, Submit, NoHide
Gui Add, Edit
, % "x482 y" y + 2 " w480 h16 vvActiveUserHome Disabled"
, % o_user[RadioActiveUser].home
}
y_Delta := 20
y_S := 128
Gui Add, GroupBox, % "x244 y" y_S " w726 h220", Distribution to...
for each, item in o_Destinations {
y := Top_Clear + y_S + y_Delta * (A_Index -1)
Gui Add, CheckBox
, % "x252 y" y " w120 h20 vCB_Destination" A_Index " Checked"Item.Active
, % Item.Name
Gui Add, Text
, % "x380 y" y + 4 " w160 h16"
, % "Last: " Item.LastUse
Gui Add, Edit
, % "x482 y" y + 2 " w480 h16 Disabled"
, % Item.Path
}
}
{ ;##TAB 2 Manage Users
Gui Tab, 2
y_Delta := 25
y_S := 62
Gui Add, GroupBox, % "x28 y" y_S " w942 h286", Present User
for each, item in o_user
{
No_of_Users := A_Index
y := Top_Clear + y_S + y_Delta * (A_Index -1)
Gui Add, Button
, % "x38 y" y " w52 h24 vvEdit_" A_Index " gEdit_" A_Index
, Edit
Gui Add, Button
, % "x92 y" y " w52 h24 disabled vvOK_" A_Index " gOK_"A_Index
, Accept
Gui Add, Edit
, % "x150 y" y + 1 " w30 h22 Limit3 disabled vvShort_" A_Index
, % Item.short
Gui Add, Edit
, % "x190 y" y + 1 " w160 h22 disabled vvName_" A_Index
, % Item.name
If A_Index > 1
Gui Add, Button
, % "x354 y" y " w52 h24 disabled vvDel_" A_Index " gDel_"A_Index
, Delete
Gui Add, Edit
, % "x410 y" y +1 " w500 h22 disabled vvHome_" A_Index
, % Item.Home
Gui Add, Button
, % "x912 y" y " w52 h24 disabled vvSel_"A_Index " gSel_"A_Index
, ...
}
If No_of_Users < 10
Gui Add, Button
, % "x38 y" y + y_Delta " w106 h24 vvadd gAdd"
, Add New User
}
{ ;##TAB 3 Manage Destinations
Gui Tab, 3
y_Delta := 25
y_S := 62
Gui Add, GroupBox, % "x28 y" y_S " w942 h286", Present User
for each, item in o_Destinations
{
No_of_Destinations := A_Index
y := Top_Clear + y_S + y_Delta * (A_Index -1)
Gui Add, Button
, % "x38 y" y " w52 h24 vdEdit_" A_Index " gdEdit_" A_Index
, Edit
Gui Add, Button
, % "x92 y" y " w52 h24 disabled vdOK_" A_Index " gdOK_"A_Index
, Accept
Gui Add, Edit
, % "x146 y" y + 1 " w160 h22 disabled Limit16 vdName_" A_Index
, % Item.name
If A_Index > 1
Gui Add, Button
, % "x308 y" y " w52 h24 disabled vdDel_" A_Index " gdDel_"A_Index
, Delete
Gui Add, Edit
, % "x362 y" y +1 " w548 h22 disabled vdPath_" A_Index
, % Item.Path
Gui Add, Button
, % "x912 y" y " w52 h24 disabled vdSel_"A_Index " gdSel_"A_Index
, ...
}
If No_of_Destinations < 10
Gui Add, Button
, % "x38 y" y + y_Delta " w106 h24 vdadd gdAdd"
, Add New Destination
}
{ ;##TAB 4 Basic Settings
Gui Tab, 4
Gui Add, Edit, x48 y64 w550 h21, Edit1
Gui Add, Edit, x48 y96 w550 h21, Edit2
Gui Add, Edit, x48 y128 w550 h21, Edit3
}
}
{ ;### Show
Gui Show,w1000 h800
loop,
{
Sleep 50
ProgressBarUpdate(1, A_Index)
if A_index >110
Break
}
}
ExitApp
Pic1:
Return
ProgressBarInit(n, x, y)
{
; n: unique Number of Bar
; x,y: Start Coordinates
Global
PGx_%n% := x
Gui Font, s6
GUI Add, Text, % " x" x + 104 " y" y - 15 " vt1_" n , % "Last"
GUIControl, Font, % " vt1_" n
GUI Add, Picture, % " x" x " y" y - 3 , pic\bar_Box.png
GUI Add, Picture, % " x" x + 101 " y" y - 6 , pic\bar100.ico
GUI Add, Picture, % " x" x + 1 " y" y - 2 " w1 vP1_" n , pic\bar.png
GUI Add, Picture, % " x" x + 1 " y" y - 2 " w1 vP2_" n , pic\bar_END.png
}
ProgressBarUpdate(n, v)
{
; n: unique Number of Bar as in Init
; value: Value 0..125
h := PGx_%n%
GuiControl,, % "P1_" n , *w%v% pic\bar.png
GuiControl, Move, % "P2_" n , % " *x" value + h " pic\bar_end.png"
GuiControl, % " vt2_" n , % v
}
for details and testing pls. download the whole project.
I am sure the function ProgressBarInit is only defined in the GUI.ahk, also if I change the name the error continues if definition & use have the same name.
Anybody has an Idea?
Thanks in advance
Andreas