如题,PB的EditMask控件有属性min和max,希望能在任何时候限制用户输入的值都在我指定的范围内,不仅在于spin控件起作用,包括键盘直接输入也需要能够限制到,我尝试在pbm_keydown事件里判断然后返回1,好像并不起作用
求一个解决方案!
------解决方案--------------------
以下内容保存为uo_editmask.sru
然后导入pbl中
利用它来创建editmask
$PBExportHeader$uo_editmask.sru
forward
global type uo_editmask from editmask
end type
end forward
global type uo_editmask from editmask
integer width = 457
integer height = 128
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = roman!
string facename = "Times New Roman"
long textcolor = 33554432
string text = "none"
borderstyle borderstyle = stylelowered!
string mask = "##0"
boolean spin = true
string minmax = "1~~200"
event ue_change pbm_enchange
end type
global uo_editmask uo_editmask
type variables
boolean ib_change
end variables
event ue_change;long ll_min, ll_max
ll_min = long(left(minmax, pos(minmax, '~~') - 1))
ll_max = long(mid(minmax, pos(minmax, '~~') + 1))
if not ib_change and ll_min > 0 and ll_max > 0 then
ib_change = true
int li_pos
li_pos = selectedstart( )
if long(text) > ll_max or long(text) < ll_min then
text = left(text, li_pos - 2) + mid(text, li_pos)
this.selecttext(li_pos - 1,0)
end if
ib_change = false
end if
end event
on uo_editmask.create
end on
on uo_editmask.destroy
end on