import win.ui;
/*DSG{{*/
var winform = win.form(text="窗体缩放批量生成plus";right=759;bottom=469;bgcolor=15780518)
winform.add(
custom={cls="custom";text="自定义控件";left=3;top=6;right=753;bottom=460;ah=1;aw=1;bgcolor=15780518;z=1}
)
/*}}*///aardio窗体缩放自动匹配批量生成plus实例//批量生成plus控件: 小图
//这个思想将会整体提升aardio应用水平
winform.plusRc = function(rows,cols){if (!rows and !cols) return ;//custom初始相对位置var left,right,top,bottom = 2,122,2,117; //plus长宽120*115var toRight = 121; //列间距+1var toBottom = 116; //行间距+1//rows,cols = 4,6; //行,列//批量生成位置buttonTab = {};for(i=1;rows;1){ //行for(j=1;cols;1){ //列table.push(buttonTab,{left+(j-1)*toRight,right+(j-1)*toRight,top+(i-1)*toBottom,bottom+(i-1)*toBottom})}}//console.dump(buttonTab)//动态生成控件//plus控件参数: edge=1;/*三维边框*/ clip=1;/*重叠裁剪*///background=null;/*背景图像*/ notify=1;/*事件回调*/for(i=1;rows*cols;1){ left,right,top,bottom = table.unpack(buttonTab[i]);//winform.add(//custom相对位置便于调整winform.custom.addCtrl(['plusPic'+i]={cls="plus";text="plus"++i;left=left;top=top;right=right;bottom=bottom;dl=1;dt=1;edge=1;repeat="scale";notify=1;z=1};)//custom.plus.notify=1;/*允许事件回调*/winform.custom['plusPic'+i].oncommand = function(id,event){winform.msgbox("plus"++i);}}
}
row,col = 3,6; //默认plus行列数量
pageLine = row*col; //每页数量
winform.plusRc(row,col); //批量生成plus//自动匹配批量生成plus
plusRcAuto = function(){for(i=1;row*col;1) winform.custom['plusPic'+i].close(); //初始化var x,y,cx,cy = win.getPos(winform.custom.hwnd);row,col = math.floor(cy/115),math.floor(cx/120); //默认plus大小winform.plusRc(row,col); //重新批量生成pluspageLine = row*col; //更新每页数量
}
plusRcAuto(); //自动匹配//custom回调判断窗体大小自动匹配批量生成plus
/**
var fx,fy,fcx,fcy = win.getPos(winform.hwnd); //原窗体大小
winform.custom.wndproc = function(hwnd,message,wParam,lParam){if message = 5/*_WM_SIZE*/{var x,y,cx,cy = win.getPos(winform.hwnd); //新窗体大小if (cx!=fcx and cy!=fcy){plusRcAuto(); //自动匹配//其他运行代码}fx,fy,fcx,fcy = x,y,cx,cy; //原窗体大小}
}
**///窗体变化
winform.adjust = function( cx,cy,wParam ) { plusRcAuto(); //自动匹配
};winform.show();
win.loopMessage();