
基础用法:
Code AardioLine:30复制
1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.import
win
.ui;import
godking.vlistEx;import
thread
.worksvar
mainForm = win
.form(text="aardio form"
;right=1031
;bottom=551
)- mainForm.add(
- button2={cls=
"button"
;text="随机进度赋值"
;left=408
;top=480
;right=560
;bottom=528
;z=2
}; - vlist={cls=
"vlistEx"
;left=10
;top=10
;right=1024
;bottom=464
;db=1
;dl=1
;dr=1
;dt=1
;edge=1
;transparent=1
;z=1
} - )
- mainForm.show();
var
t = { fields={"序号"
,"网址"
,"文件"
,"进度"
} };for
(i=1
;30
;1
){- ..
table
.push(t,{"序号"
="[@rowindex]"
}); - }
- mainForm.vlist.setTable(t,,{scale=
true
,1
,1
,1
,2
},1,,,); - mainForm.vlist.fillParent(-1,-1);
- mainForm.vlist.enableRowProgress(
true
,4
); - mainForm.button2.oncommand =
function
(id,event){ -
- mainForm.vlist.setCellText( 4,4,
math
.random(0
,100
)); - mainForm.vlist.setCellText( 5,4,
"非数值文本:"
++math
.random(0
,100
)); - mainForm.vlist.setCellText( 6,4,
math
.random(0
,100
)++":我也是数值,因为我数字开头"
); - mainForm.vlist.setCellText( 7,4,
"我是一串文本"
); - }
win
.loopMessage();
使用内置函数启用绘制整行背景进度条,多线程下载示例:
Code AardioLine:92复制
1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.85.86.87.88.89.90.91.92.import
win
.ui;import
godking.vlistEx;import
thread
.worksvar
mainForm = win
.form(text="aardio form"
;right=1031
;bottom=551
)- mainForm.add(
- button={cls=
"button"
;text="停止下载"
;left=296
;top=480
;right=448
;bottom=528
;z=2
}; - button2={cls=
"button"
;text="开始下载"
;left=520
;top=480
;right=672
;bottom=528
;z=3
}; - vlist={cls=
"vlistEx"
;left=10
;top=10
;right=1024
;bottom=464
;db=1
;dl=1
;dr=1
;dt=1
;edge=1
;transparent=1
;z=1
} - )
var
t = { fields={"序号"
,"url"
,"保存文件"
,"下载进度"
} };for
(i=1
;30
;1
){- ..
table
.push(t,{"序号"
="[@rowindex]"
}); - }
- mainForm.vlist.setTable(t,,{scale=
true
,0
.5
,5
,3
,2
},1,,,true); - mainForm.vlist.fillParent();
- ..
io
.createDir("\down"
); - mainForm.vlist.enableRowProgress(
true
,4
); import
thread
.commandthread
.command.instance().setinfo = function
(row,v,url,file){-
if
-
if
- mainForm.vlist.setCellText(row,
4
,v); - }
var
work = thread
.works(5
,-
function
(param) { -
if
thread
.var
("stop"
).get() return
; -
import
godking.http; -
import
thread
.command; -
thread
.command.setinfo(param.index,"开始 "
++param.index,param.url); -
var
t,n={info = "超时或终止"
},0
; -
var
callback = function
(id,v,all,url,file){ -
thread
.command.setinfo(id,..math
.round((v:0
)*100
/all,2
)++"%"
,url,file); -
return
thread
.var
("stop"
).get(); - };
-
do
{ - n++;
-
if
n>3
or
thread
.var
("stop"
).get() break
; - _,_,t = godking.http({
- url = param.url;
- callback = callback;
- callbackID = param.index;
- file =
"\down\QQ_"
+param.index+".exe"
; - fileResume =
true
; - })
- }
while
( !t.success and
t.info!=="下载被终止"
) -
if
t.success===true
{ -
thread
.command.setinfo(param.index,"下载完毕"
,param.url,t.file); - }
elseif
t.success===false
{ -
thread
.command.setinfo(param.index,"下载失败:"
++(t.info:""
)++..math
.round(t.downsize*100
/t.allsize,2
)++"%"
,param.url,t.file); - }
else
{ -
thread
.command.setinfo(param.index,"下载失败:"
++(t.info:""
)); - }
-
return
; - }
- );
- mainForm.show();
- mainForm.button.oncommand =
function
(id,event){ -
thread
.var
("stop"
).set(true
); - }
- mainForm.button2.oncommand =
function
(id,event){ -
thread
.var
("stop"
).set(false
); - mainForm.vlist.setTable(t,false,,,,,true);
-
for
(i=1
;50
;1
){ -
if
thread
.var
("stop"
).get() return
; - work.push({index=i,url=
"https://dldir1.qq.com/qqfile/qq/QQNT/Windows/QQ_9.9.15_240902_x86_01.exe"
}); - }
- }
- mainForm.onClose =
function
(hwnd,message,wParam,lParam){ -
import
process - process().terminate();
- }
- mainForm.vlist.autoRedraw =
false
; - mainForm.setInterval(
-
function
(){ - mainForm.vlist.redraw(
true
); - },
200
- )
win
.loopMessage();
高级点的用法,使用事件函数启用绘制整行背景进度条,多线程下载示例:
Code AardioLine:97复制
1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.85.86.87.88.89.90.91.92.93.94.95.96.97.import
win
.ui;import
godking.vlistEx;import
thread
.worksvar
mainForm = win
.form(text="aardio form"
;right=1031
;bottom=551
)- mainForm.add(
- button={cls=
"button"
;text="停止下载"
;left=296
;top=480
;right=448
;bottom=528
;z=2
}; - button2={cls=
"button"
;text="开始下载"
;left=520
;top=480
;right=672
;bottom=528
;z=3
}; - vlist={cls=
"vlistEx"
;left=10
;top=10
;right=1024
;bottom=464
;db=1
;dl=1
;dr=1
;dt=1
;edge=1
;transparent=1
;z=1
} - )
var
t = { fields={"序号"
,"url"
,"保存文件"
,"下载进度"
} };for
(i=1
;30
;1
){- ..
table
.push(t,{"序号"
="[@rowindex]"
}); - }
- mainForm.vlist.setTable(t,,{scale=
true
,0
.5
,5
,3
,2
},1,,,true); - mainForm.vlist.fillParent();
- ..
io
.createDir("\down"
); - mainForm.vlist.onDrawCellRectBg =
function
(row,col,hdc,rect,bkcolor,text,font,align,valign,recall){ -
-
if
mainForm.vlist.drawRowProgress(row,4
,hdc,rect) return
true
; -
-
if
owner
.getCellText(row,"下载进度"
)=="下载完毕"
return
false
,0xE6F0FA; - }
import
thread
.command;thread
.command.instance().setinfo = function
(row,v,url,file,rowprogress){-
if
-
if
- mainForm.vlist.setCellText(row,
4
,v); - }
var
work = thread
.works(5
,-
function
(param) { -
if
thread
.var
("stop"
).get() return
; -
import
godking.http; -
import
thread
.command; -
thread
.command.setinfo(param.index,"开始 "
++param.index,param.url,,true
); -
var
t,n={info = "超时或终止"
},0
; -
var
callback = function
(id,v,all,url,file){ -
thread
.command.setinfo(id,..math
.round((v:0
)*100
/all,2
)++"%"
,url,file,null
); -
return
thread
.var
("stop"
).get(); - };
-
do
{ - n++;
-
if
n>3
or
thread
.var
("stop"
).get() break
; - _,_,t = godking.http({
- url = param.url;
- callback = callback;
- callbackID = param.index;
- file =
"\down\QQ_"
+param.index+".exe"
; - fileResume =
true
; - })
- }
while
( !t.success and
t.info!=="下载被终止"
); -
if
t.success===true
{ -
thread
.command.setinfo(param.index,"下载完毕"
,param.url,t.file,false
); - }
elseif
t.success===false
{ -
thread
.command.setinfo(param.index,"下载失败:"
++(t.info:""
)++..math
.round(t.downsize*100
/t.allsize,2
)++"%"
,param.url,t.file,false
); - }
else
{ -
thread
.command.setinfo(param.index,"下载失败:"
++(t.info:""
),,,false
); - }
-
return
; - }
- );
- mainForm.show();
- mainForm.button.oncommand =
function
(id,event){ -
thread
.var
("stop"
).set(true
); - }
- mainForm.button2.oncommand =
function
(id,event){ -
thread
.var
("stop"
).set(false
); - mainForm.vlist.setTable(t,false,,,,,true);
-
for
(i=1
;50
;1
){ -
if
thread
.var
("stop"
).get() return
; - work.push({index=i,url=
"https://dldir1.qq.com/qqfile/qq/QQNT/Windows/QQ_9.9.15_240902_x86_01.exe"
}); - }
- }
- mainForm.onClose =
function
(hwnd,message,wParam,lParam){ -
import
process; - process().terminate();
- }
- mainForm.vlist.autoRedraw =
false
; - mainForm.setInterval(
-
function
(){ - mainForm.vlist.redraw(
true
); - },
200
- )
win
.loopMessage();