1、单线程顺序下载演示:
import win.ui;
import godking.vlistEx;
/*DSG{{*/
mainForm = win.form(text="vlistEx - table adapter";right=551;bottom=423)
mainForm.add(
vlist={cls="vlistEx";left=10;top=10;right=544;bottom=416;border=1;db=1;dl=1;dr=1;dt=1;transparent=1;z=1}
)
/*}}*/
var t = { fields={"序号","姓名","年龄","地址","政治面貌"} };
for(i=1;10;1){
var tt={};
tt["序号"]="[@rowindex]";
tt["姓名"]=math.random(1000,9999)+"姓名";
tt["年龄"]=math.random(10,99);
tt["地址"]=math.random(1000,9999)+"地址";
tt["政治面貌"]="党员";
..table.push(t,tt);
}
mainForm.vlist.setTable(t,,-1,1);
mainForm.vlist.padding = 0;
mainForm.show();
var pros = {};
var crow = 1;
mainForm.setInterval(
function(){
pros[crow] = (pros[crow]:0)+1;
mainForm.vlist.redrawRow(crow);
if pros[crow]=100 crow++;
if crow>mainForm.vlist.count {
..win.msgbox("下载完毕");
return false;
}
},10
)
mainForm.vlist.onDrawCellRectBg = function(row,col,hdc,rect,bkcolor,text){
var pro = pros[row]:0;
if !pro return ;
if rect.left<0 rect.left=0;
if rect.right>owner.width*(pro/100) rect.right=owner.width*(pro/100);
if rect.right>rect.left {
gdi.fillRect(hdc,pro=100?0x90EE90:0x7AA0FF,rect);
return true;
}
}
win.loopMessage();
2、多线程同时下载演示:
import win.ui;
import godking.vlistEx;
/*DSG{{*/
mainForm = win.form(text="vlistEx - table adapter";right=551;bottom=423)
mainForm.add(
vlist={cls="vlistEx";left=10;top=10;right=544;bottom=416;border=1;db=1;dl=1;dr=1;dt=1;transparent=1;z=1}
)
/*}}*/
var t = { fields={"序号","姓名","年龄","地址","政治面貌"} };
for(i=1;10;1){
var tt={};
tt["序号"]="[@rowindex]";
tt["姓名"]=math.random(1000,9999)+"姓名";
tt["年龄"]=math.random(10,99);
tt["地址"]=math.random(1000,9999)+"地址";
tt["政治面貌"]="党员";
..table.push(t,tt);
}
mainForm.vlist.setTable(t,,-1,1);
mainForm.show();
mainForm.vlist.onDrawCellRectBg = function(row,col,hdc,rect,bkcolor,text){
rect.inflate(mainForm.vlist.padding,0);
var pro = owner.getRowMeta(row /*行号*/)["jindu"];
if !pro return ;
if rect.left<0 rect.left=0;
if rect.right>owner.width*(pro/100) rect.right=owner.width*(pro/100);
if rect.right>rect.left {
gdi.fillRect(hdc,pro=100?0x90EE90:0x7AA0FF,rect);
return true;
}
}
for(i=1;mainForm.vlist.count;1){
mainForm.vlist.addRowMeta(i /*行号*/,"jindu"/*属性名称*/,0/*属性值*/);
thread.invoke(
function(mainForm,row){
do{
var jindu = mainForm.vlist.getRowMeta(row /*行号*/)["jindu"];
jindu += math.random(0,1);
mainForm.vlist.addRowMeta(row /*行号*/,"jindu"/*属性名称*/,jindu/*属性值*/);
mainForm.vlist.redrawRow(row);
if jindu=100 return ;
thread.delay(10);
}while(true)
},mainForm,i
)
}
win.loopMessage();