只需要指定行列按钮数量,自动适应宽度。加入数据表,即可快捷使用。对于宽度,可调整行列按钮数量,或调整数据表内容。

Code AardioLine:69复制
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.import
win
.ui;var
winform = win
.form(text="aardio form"
;right=759
;bottom=469
)- winform.add(
- custom={cls=
"custom"
;text="自定义控件"
;left=8
;top=8
;right=760
;bottom=464
;ah=1
;aw=1
;dl=1
;dt=1
;z=1
} - )
namespace
mylib{import
math
;import
table
;import
console;- btnTabSet =
function
(winW,winH,btnMargin,btnRows,btnCols){ -
var
btnW = math
.floor((winW-btnMargin*btnCols)/btnCols); -
var
btnH = math
.floor((winH-btnMargin*btnRows)/btnRows); -
-
var
btnTab = {} -
for
(i=1
;btnRows;1
){ -
for
(j=1
;btnCols;1
){ - btnLeft = j*btnMargin+(j-
1
)*btnW; - btnTop = i*btnMargin+(i-
1
)*btnH; - btnRight = btnLeft+btnW;
- btnBottom = btnTop + btnH;
-
table
.push(btnTab,{left=btnLeft,top=btnTop,right=btnRight,bottom=btnBottom}); - }
- }
-
return
btnTab; - }
- }
import
console;- btnTab = {}
- btnMargin =
2
; - btnRows,btnCols =
10
,5
; - winform.btnDisp =
function
(){ -
-
for
(i=1
; -
if
winform.custom['button'
+i] winform.custom['button'
+i].close(); - }
-
-
- winW,winH = winform.custom.width,winform.custom.height;
- btnTab = mylib.btnTabSet(winW,winH,btnMargin,btnRows,btnCols)
-
-
-
for
(i=1
; - winform.custom.addCtrl(
- [
'button'
+i]={cls="button"
;text="按钮"
++i; - left=btnTab[i].left;top=btnTab[i].top;right=btnTab[i].right;bottom=btnTab[i].bottom;dl=
1
;dt=1
;flat=1
;z=1
}; - )
- winform.custom[
'button'
+i].oncommand = function
(id,event){ - winform.msgbox(
owner
.text) - }
- }
- }
- winform.adjust =
function
( cx,cy,wParam ) { - winform.btnDisp();
- };
- winform.show();
win
.loopMessage();
不断的练习,终于进入写库阶段了,向各位大佬学习