求助一个按钮控件的问题!
在网上找了一个身份证信息采集代码,放到了表单的COMMAND1的Click中,现在是每点击一次COMMAND1(开始)按钮可以采集一条身份证信息,现在的想法是只点击一次COMMAND1(开始)按钮可以连续采集身份证信息,就是采集完第一位同学的身份证信息,不用点击COMMAND1(开始)按钮,可以直接可以采集第二名,第三名,第四名……N名同学的身份证信息,再添加一个COMMAND2(停止)按钮,点击一下COMMAND2(停止)按钮,停止采集,不想用计时器,请位各位高手帮助指导一下,小学生在此拜过!程序代码:
DECLARE Integer SDT_OpenPort IN sdtapi.dll Integer iPort DECLARE Integer SDT_ClosePort IN sdtapi.dll Integer iPort DECLARE Integer SDT_StartFindIDCard IN sdtapi.dll Integer iPort, String @pucManaInfo, Integer iIfOpen DECLARE Integer SDT_SelectIDCard IN sdtapi.dll Integer iPort, String @pucManaMsg, Integer iIfOpen DECLARE Integer SDT_ReadBaseMsg IN sdtapi.dll Integer iPort, String @pucCHMsg, Integer @puiCHMsgLen, String @pucPHMsg, Integer @puiPHMsgLen, Integer iIfOpen DECLARE Integer GetBmp IN WltRS.dll string wlt_file, integer intf DECLARE Long GdipLoadImageFromFile IN Gdiplus.dll String cFile, Long @ nativeImage DECLARE Long GdipSaveImageToFile IN Gdiplus.dll Long nativeImage, String cFile, String EncoderClsID, String EncoderParameters DECLARE Long GdipDisposeImage IN Gdiplus.dll Long nativeImage LOCAL iRet As Integer && 返回码 LOCAL iPort As Integer && 端口号 LOCAL iIfOpen As Integer && 是否需要打开端口 LOCAL find_sta find_sta=.t. LOCAL pucManaInfo As String LOCAL pucManaMsg As String LOCAL pucCHMsg As String && 文字信息 LOCAL pucPHMsg As String && 照片信息 LOCAL pucFPMsg As String && 指纹信息 LOCAL uiCHMsgLen As Integer, uiPHMsgLen As Integer iRet = 0 pucManaInfo = SPACE(4) pucManaMsg = SPACE(8) pucCHMsg = SPACE(512) pucPHMsg = SPACE(1024) pucFPMsg = SPACE(1024) uiCHMsgLen = 0 uiPHMsgLen = 0 iPort = 1001 && 端口设置为 1001 代表是 USB 设备 iIfOpen = 0 IF iIfOpen = 0 iRet = SDT_OpenPort(iPort) IF iRet != 144 MESSAGEBOX("SDT_OpenPort 错误, 错误代码为 " + LTRIM(STR(iRet)), 16, '错误') SDT_ClosePort(iPort) RETURN ENDIF ENDIF DO WHILE .T. && 找卡 iRet = SDT_StartFindIDCard(iPort, @pucManaInfo, iIfOpen) IF iRet = 159 iRet = SDT_SelectIDCard(iPort, @pucManaMsg, iIfOpen) IF iRet == 144 EXIT ENDIF ENDIF *IF MESSAGEBOX("没有找到身份证,请放身份证?", 32 + 4, '询问') <> 6 * find_sta=.f. * EXIT *ENDIF ENDDO iRet = SDT_ReadBaseMsg(iPort, @pucCHMsg, @uiCHMsgLen, @pucPHMsg, @uiPHMsgLen, iIfOpen) IF iRet != 0x90 MESSAGEBOX("SDT_ReadBaseMsg 错误, 错误代码为 " + LTRIM(STR(iRet)), 16, '错误') IF iIfOpen = 0 SDT_ClosePort(iPort) find_sta=.f. RETURN ENDIF ENDIF *WAIT WINDOW "身份证信息获取成功!" NOWAIT tmp_read=STRCONV(left(pucCHMsg,uiCHMsgLen),6) xm_read=ALLTRIM(LEFTC(tmp_read,15))&&读出的字符串前15位是姓名 xbpd = SUBSTRC(tmp_read,16,1) &&读出的字符串前16位是性别,1代表男,2代表女 mzpd = SUBSTRC(tmp_read,17,2) &&读出的字符串前17-18位是民族,01是汉族 tmp_rq = SUBSTRC(tmp_read,19,8) &&读出的字符串前19-25位是出生日期 thisform.label2.Caption=ALLTRIM(xm_read)+'身份证获取成功' IF xbpd="1" xb_read="男" ELSE xb_read="女" ENDIF DO CASE CASE mzpd = "01" mz_read = "汉族" CASE mzpd = "02" mz_read = "蒙古族" CASE mzpd = "03" mz_read = "回族" CASE mzpd = "04" mz_read = "藏族" CASE mzpd = "05" mz_read = "维吾尔族" CASE mzpd = "06" mz_read = "苗族" CASE mzpd = "07" mz_read = "彝族" CASE mzpd = "08" mz_read = "壮族" CASE mzpd = "09" mz_read = "布依族" CASE mzpd = "10" mz_read = "朝鲜族" CASE mzpd = "11" mz_read = "满族" CASE mzpd = "12" mz_read = "侗族" CASE mzpd = "13" mz_read = "瑶族" CASE mzpd = "14" mz_read = "白族" CASE mzpd = "15" mz_read = "土家族" CASE mzpd = "16" mz_read = "哈尼族" CASE mzpd = "17" mz_read = "哈萨克族" CASE mzpd = "18" mz_read = "傣族" CASE mzpd = "19" mz_read = "黎族" CASE mzpd = "20" mz_read = "傈僳族" CASE mzpd = "21" mz_read = "佤族" CASE mzpd ="22" mz_read = "畲族" CASE mzpd = "23" mz_read = "高山族" CASE mzpd ="24" mz_read = "拉祜族" CASE mzpd = "25" mz_read = "水族" CASE mzpd = "26" mz_read = "东乡族" CASE mzpd = "27" mz_read = "纳西族" CASE mzpd = "28" mz_read = "景颇族" CASE mzpd = "29" mz_read = "柯尔克孜族" CASE mzpd = "30" mz_read = "土族" CASE mzpd = "31" mz_read = "达翰尔族" CASE mzpd = "32" mz_read = "仫佬族" CASE mzpd = "33" mz_read = "羌族" CASE mzpd = "34" mz_read = "布朗族" CASE mzpd = "35" mz_read = "撒拉族" CASE mzpd = "36" mz_read = "毛南族" CASE mzpd = "37" mz_read = "仡佬族" CASE mzpd = "38" mz_read = "锡伯族" CASE mzpd = "39" mz_read = "阿昌族" CASE mzpd = "40" mz_read = "普米族" CASE mzpd ="41" mz_read = "塔吉克族" CASE mzpd = "42" mz_read = "怒族" CASE mzpd = "43" mz_read = "乌孜别克族" CASE mzpd = "44" mz_read = "俄罗斯族" CASE mzpd = "45" mz_read = "鄂温克族" CASE mzpd = "46" mz_read = "德昂族" CASE mzpd = "47" mz_read = "保安族" CASE mzpd = "48" mz_read = "裕固族" CASE mzpd = "49" mz_read = "京族" CASE mzpd = "50" mz_read = "塔塔尔族" CASE mzpd = "51" mz_read = "独龙族" CASE mzpd = "52" mz_read = "鄂伦春族" CASE mzpd = "53" mz_read = "赫哲族" CASE mzpd = "54" mz_read = "门巴族" CASE mzpd = "55" mz_read = "珞巴族" CASE mzpd ="56" mz_read = "基诺族" CASE mzpd = "57" mz_read = "其它" CASE mzpd = "98" mz_read = "外国人入籍" ENDCASE SET SAFETY OFF SET CENTURY ON SET DATE TO ANSI csrq_read = CTOD(SUBSTR(tmp_rq,1,4) + "/" + SUBSTR(tmp_rq,5,2) + "/" + SUBSTR(tmp_rq,7,2)) &&出生日期 dz_read = SUBSTRC(tmp_read,27,35) &&地址的数据 sfzhm_read = SUBSTRC(tmp_read,62,18) &&身份证号码的数据 qfjg_read = ALLTRIM(SUBSTRC(tmp_read,80,15)) &&签发机关的数据 tmp_rqq = SUBSTRC(tmp_read,95,8) &&签发日期 tmp_rqz = SUBSTRC(tmp_read,103,8) &&有限期限 yxqq_read = CTOD(SUBSTR(tmp_rqq,1,4) + "/" + SUBSTR(tmp_rqq,5,2) + "/" + SUBSTR(tmp_rqq,7,2) ) && 有效起始日 yxqz_read = CTOD(SUBSTR(tmp_rqz,1,4) + "/" + SUBSTR(tmp_rqz,5,2)+"/"+SUBSTR(tmp_rqz,7,2)) && 有效终止日 qtxx_read = RIGHTC(tmp_read,18)&&其他内容,暂时不知道是什么 photo_tmp = SYS(5) + SYS(2003) + "\" + ALLTRIM(sfzhm_read) + ".wlt" &&这里是获得照片的程序 =STRTOFILE(LEFT(pucPHMsg,uiPHMsgLen),photo_tmp,1) *IF iIfOpen = 0 &&关闭端口 * SDT_ClosePort(iPort) * SDT_OpenPort(iPort) *ENDIF photo_bmp = SYS(5) + SYS(2003) + "\" + ALLTRIM(sfzhm_read) + ".bmp" photo_jpg = SYS(5) + SYS(2003) + "\photos\" + ALLTRIM(sfzhm_read) + ".jpg" *CLEAR *? "姓名:" + xm_read *? "性别:" + xb_read *? "民族:" + mz_read *? "出生日期:" + DTOC(csrq_read) *? "地址:" + dz_read *? "身份证号:" + sfzhm_read *? "签发机关:" + qfjg_read *? "有效期起:" + DTOC(yxqq_read) *? "有效期止:" + DTOC(yxqz_read) *? "其它信息:" + qtxx_read *? "照片路径:" + photo_jpg a=GetBmp(photo_tmp,2) *?a IF NOT FILE(SYS(5) + SYS(2003) + "\身份证信息.dbf") CREATE TABLE 身份证信息 FREE (身份证号 C(18),姓名 C(32),性别 C(2),民族 C(10),出生日期 D,地址 C(72),发证机关 C(32),有效期始 D,有效期止 D,照片路径 C(254)) INDEX ON 身份证号 TO 身份证信息 ASCENDING ELSE USE 身份证信息 INDEX ON 身份证号 TO 身份证信息 ASCENDING ENDIF *SEEK sfzhm_read IF 身份证号=sfzhm_read then MESSAGEBOX("该生身份证号已经存在!",0,"提示") else IF NOT FOUND() THEN INSERT INTO 身份证信息 VALUES (sfzhm_read,xm_read,xb_read,mz_read,csrq_read,dz_read,qfjg_read,yxqq_read,yxqz_read,photo_jpg) ENDIF endif USE