当窗口中有多个组件排列显示,一个窗口容纳不下时,需要滚动显示。
显示效果

以下为实现代码:
Code AardioLine:39复制
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.import
win
.ui;var
winform = win
.form(text="aardio form"
;right=423
;bottom=469
)- winform.add(
- custom={cls=
"custom"
;text="自定义控件"
;left=8
;top=8
;right=416
;bottom=456
;z=1
} - )
- winform.show();
var
dpi= winform.dpiScaleYfor
(i=0
;7
;1
){-
var
ty = dpi+i*180
*dpi; -
var
th = ty + 30
*dpi; -
var
py = ty + 30
*dpi; -
var
ph = py + 150
*dpi -
var
title = i+1
++"队"
; - winform.custom.addCtrl(
- [
"title"
++i+1
] = {cls="plus"
;text=title;left=0
;top=ty;right=winform.custom.width;bottom=th;align="left"
;bgcolor=16711808
;color=16777215
;font=LOGFONT(h=-16
;weight=700
);forecolor=255
;linearGradient=45
;notify=1
;textPadding={left=10
};z=i}; - [
"plus"
++i+1
] = {cls="plus"
;left=0
;top=py;right=winform.custom.width;bottom=ph;ah=1
;autohscroll=false
;bgcolor=0xFFFFFFFF;autovscroll=false
;aw=1
;db=1
;dl=1
;dr=1
;dt=1
;notify=1
;z=i} - )
- }
var
minbottom=winform.custom.height;var
maxbottom=winform.custom.plus8.bottom;import
win
.ui.scrollbar;var
sc = win
.ui.scrollbar(winform.custom,true
);- sc.setRange(
0
,maxbottom - minbottom); - winform.custom.wndproc =
function
(hwnd,message,wParam,lParam){ -
if
message = 0x115 { -
if
wParam===1
{ -
if
winform.custom.plus8.bottom<=minbottom return
true
; - }
elseif
wParam===0
{ -
if
winform.custom.plus8.bottom>=maxbottom return
true
; - }
- }
- }
win
.loopMessage();