pb9 验证码

效果图:

代码:

创建Standard visual----DataWindow 对象;命名为 vo_verification

获取验证码值:控件名称.text

forward
global type vo_verification from datawindow
end type
end forward

global type vo_verification from datawindow
integer width = 549
integer height = 320
boolean livescroll = true
end type
global vo_verification vo_verification

type variables
string text
end variables

forward prototypes
public subroutine of_draw_code ()
end prototypes

public subroutine of_draw_code ();string ls_sCode[]
string ls_text,ls_syntax,ls_content
dec li_radian,li_random
int li_index,li_x,li_y,li_x2,li_y2
int li_i
long ll_rgb
int li_r,li_g,li_b
ls_sCode = {"A","B","C","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","W","X","Y","Z","1","2","3","4","5","6","7","8","9","0"}

Randomize(0)	

for li_i = 1 to 4
	this.modify("destroy char_"+string(li_i))
	li_index = rand(upperbound(ls_sCode))
	ls_text = ls_sCode[li_index] //随机内容
	li_radian = rand(300)
	li_random = rand(100) / 100 
	if li_i =1 then
		
	elseif li_i =1 then
	elseif li_i =1 then
	else
	end if
	//li_x=(((this.width -30)/4) *li_i) - 110 //文字x坐标
	li_x=((this.width -5 ) / 4) * li_i
	li_x = (li_x /1.5) -30
	li_y = 20 + li_random * 8 //文字y坐标
	li_r = (rand(100) / 100 )*256
	li_g = (rand(100) / 100 )*256
	li_b = (rand(100) / 100 )*256
	ll_rgb = 65536 * li_b + 256 * li_g + li_r

	this.Modify('create text(band=detail alignment="2" text="'+ls_text+'" border="0"  &
	color="'+string(ll_rgb)+'" x="'+string(li_x)+'" y="'+string(li_y)+'" height="96" width="100" html.valueishtml="0"  &
	name=char_'+string(li_i)+' visible="1"  font.face="微软雅黑" font.height="-16" font.weight="700"  &
	font.family="2" font.pitch="2" font.charset="134" background.mode="1" background.color="536870912" )')
	this.modify("char_"+string(li_i)+".font.escapement="+string(li_radian)+"")
	ls_content=ls_content+ls_text
next

this.text = ls_content
//线条
for li_i = 1 to 5
	this.modify("destroy line_"+string(li_i))
	li_r = (rand(100) / 100 )*256
	li_g = (rand(100) / 100 )*256
	li_b = (rand(100) / 100 )*256
	ll_rgb = 65536 * li_b + 256 * li_g + li_r

	li_x = (rand(100) / 100 )*this.width 
	li_x2 = (rand(100) / 100 )*this.width 
	li_y = (rand(100) / 100 )*this.height 
	li_y2 =(rand(100) / 100 )*this.height 
	this.Modify('create line(band=detail x1="'+string(li_x)+'" y1="'+string(li_x2)+'" &
	x2="'+string(li_y)+'" y2="'+string(li_y2)+'"  name=line_'+string(li_i)+' visible="1" pen.style="0" &
	pen.width="5" pen.color="'+string(ll_rgb)+'"  background.mode="2" background.color="1073741824" )')
next

//圆点
for li_i = 1 to 30
	this.modify("destroy oval_"+string(li_i))
	li_r = (rand(100) / 100 )*256
	li_g = (rand(100) / 100 )*256
	li_b = (rand(100) / 100 )*256
	ll_rgb = 65536 * li_b + 256 * li_g + li_r
	
	li_x = long((rand(100) / 100 )*this.width)
	li_y = long((rand(100) / 100 )*this.height)
	this.Modify('create ellipse(band=detail x="'+string(li_x)+'" y="'+string(li_y)+'" height="19" width="18"  &
					name=oval_'+string(li_i)+' visible="1" brush.hatch="6" brush.color="'+string(ll_rgb)+'" pen.style="5" pen.width="4" &
					pen.color="'+string(ll_rgb)+'"  background.mode="2" background.color="0" )&
					')
next

end subroutine

on vo_verification.create
end on

on vo_verification.destroy
end on

event constructor;string ls_syntax

ls_syntax ='release 9; &
datawindow(units=0 timer_interval=0 color=1073741824 processing=0 HTMLDW=no print.printername="" print.documentname="" print.orientation = 0 print.margin.left = 110 print.margin.right = 110 print.margin.top = 96 print.margin.bottom = 96 print.paper.source = 0 print.paper.size = 0 print.canusedefaultprinter=yes print.prompt=no print.buttons=no print.preview.buttons=no print.cliptext=no print.overrideprintjob=no print.collate=yes hidegrayline=no )&
summary(height=0 color="536870912" )&
footer(height=0 color="536870912" )&
detail(height=998 color="536870912" )&
table(column=(type=char(10) updatewhereclause=yes name=a dbname="a" )&
 )&
htmltable(border="1" )&
htmlgen(clientevents="1" clientvalidation="1" clientcomputedfields="1" clientformatting="0" clientscriptable="0" generatejavascript="1" encodeselflinkargs="1" netscapelayers="0" )&
export.xml(headgroups="1" includewhitespace="0" metadatatype=0 savemetadata=0 )&
import.xml()&
export.pdf(method=0 distill.custompostscript="0" xslfop.print="0" )'

this.create(ls_syntax)
this.insertrow(0)
this.of_draw_code()
end event

event clicked;this.of_draw_code()

end event

 

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值