USB比較難抓數(shù)據(jù),建議是USB模擬串口,或者直接就是串口,這樣數(shù)據(jù)比較好抓。
創(chuàng)新互聯(lián)是專業(yè)的行唐網(wǎng)站建設(shè)公司,行唐接單;提供網(wǎng)站設(shè)計(jì)、做網(wǎng)站,網(wǎng)頁設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行行唐網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來合作!
USB上傳模式是鼠標(biāo)光標(biāo)在哪數(shù)據(jù)就上傳在哪,所以你抓USB的數(shù)據(jù)的很難!
X貓-思刊辦公專營店
Public Function TranBlt(DestHdc As Long, X As Long, Y As Long, W As Long, H As Long, srcHdcOrBmp As Long, Optional srcX As Integer, Optional srcY As Integer, Optional srcW As Long, Optional srcH As Long, Optional tc As Long = -1, Optional IsBmp As Boolean) As Long
'srcHdcOrBmp參數(shù) 傳入的可以是hdc也可以是Bmp對(duì)象的Handle,
'IsBmp參數(shù) 為真時(shí)srcHdcOrBmp代表Bmp對(duì)象的Handle,為假時(shí)代表hdc
'返回值 成功時(shí)返回透明色,不成功時(shí)返回-1
Dim tHdc(3) As MemHdc
Dim J As Long, oc As Long, I As Long, Bm As BITMAP, cc As Long, NewDc As Long
Dim sw As Long, sh As Long, sBmp As Long, sHdc As Long, obm As Long, NewX As Long, NewY As Long
If DestHdc = 0 Or srcHdcOrBmp = 0 Or W = 1 And H = 1 Then GoTo fail
If IsBmp Then '若傳入的是Bmp句柄,需為其創(chuàng)建一個(gè)臨時(shí)DC
sBmp = srcHdcOrBmp
tHdc(3) = NewMyHdc(DestHdc, 0, 0, srcHdcOrBmp)
sHdc = tHdc(3).hdc
Else
sHdc = srcHdcOrBmp
If srcW = 0 Then sBmp = GetCurrentObject(sHdc, 7)
End If
If sHdc = 0 Or sBmp = 0 Then GoTo fail
If srcW = 0 Then '若沒有提供源圖大小,需取得整個(gè)源圖大小
GetObj sBmp, Len(Bm), Bm
sw = Bm.bmWidth - srcX
sh = Bm.bmHeight - srcY
Else
sw = srcW
sh = srcH
End If
If sw 1 Or sh 1 Then GoTo fail
If tc = -1 Then
cc = GetPixel(sHdc, srcX, srcY) '將左上角第一個(gè)像素作為源圖背景色,用于透明
Else
cc = tc
End If
If W sw Or H sh Then
tHdc(2) = NewMyHdc(DestHdc, W, H)
StretchBlt tHdc(2).hdc, 0, 0, W, H, sHdc, srcX, srcY, sw, sh, vbSrcCopy
'先將源圖縮放,下面步驟就一樣了。
NewDc = tHdc(2).hdc
Else
NewDc = sHdc
NewX = srcX
NewY = srcY
End If
BitBlt DestHdc, X, Y, W, H, NewDc, NewX, NewY, vbSrcInvert
'將源圖先反色(XOR)繪入目標(biāo)圖,若源圖背景為黑色,此步可省
'下面是制作Mask圖的方法
I = CreateBitmap(W, H, 1, 1, ByVal 0) '建立單色位圖
tHdc(0) = NewMyHdc(DestHdc, 0, 0, I) '為單色圖建立新DC,并選入
tHdc(1) = NewMyHdc(DestHdc, W, H) '另建一個(gè)彩色圖及DC,用于存放Mask圖
oc = SetBkColor(NewDc, cc) '將源圖背景色改為透明色
BitBlt tHdc(0).hdc, 0, 0, W, H, NewDc, NewX, NewY, vbSrcCopy
'先將源圖繪入單色DC,由此產(chǎn)生只有正反的Mask圖,背景色(透明色)為黑,其它為白
SetBkColor NewDc, oc '恢復(fù)源圖背景色,不是必須的,但這是個(gè)好習(xí)慣。
BitBlt tHdc(1).hdc, 0, 0, W, H, tHdc(0).hdc, 0, 0, vbSrcCopy
'單色DC必須復(fù)制進(jìn)彩色DC才能進(jìn)行后面的的AND運(yùn)算
'Mask圖完成,并已放入彩色DC
BitBlt DestHdc, X, Y, W, H, tHdc(1).hdc, 0, 0, vbSrcAnd '標(biāo)準(zhǔn)透明繪圖:選將Mask圖用And運(yùn)算繪入,
BitBlt DestHdc, X, Y, W, H, NewDc, NewX, NewY, vbSrcInvert '再將源圖以反色(XOR)繪入一次
DelMyHdc tHdc(0)
DelMyHdc tHdc(1)
If tHdc(2).hdc 0 Then DelMyHdc tHdc(2)
If tHdc(3).hdc 0 Then DelMyHdc tHdc(3)
TranBlt = cc
Exit Function
fail:
If tHdc(3).hdc 0 Then DelMyHdc tHdc(3)
TranBlt = -1
End Function
Private Function NewMyHdc(dHdc As Long, W As Long, H As Long, Optional Bm As Long) As MemHdc
With NewMyHdc
.hdc = CreateCompatibleDC(dHdc)
If Bm = 0 Then
.Bmp = CreateCompatibleBitmap(dHdc, W, H)
Else
.Bmp = Bm
End If
.obm = SelectObject(.hdc, .Bmp)
End With
End Function
Private Function DelMyHdc(MyHdc As MemHdc, Optional nobmp As Boolean) As MemHdc
With MyHdc
If .hdc 0 And .obm 0 Then SelectObject .hdc, .obm
If nobmp = False And .Bmp 0 Then DeleteObject .Bmp
If .hdc 0 Then DeleteDC .hdc
End With
End Function
把這個(gè)函數(shù)放在一個(gè)BAS里,然后在窗體里
TranBlt pic.hdc, X,Y,W,H,PIC2.Picture.Handle, _
TX,TY,TW,TH, , True
就OK
93條碼和CODE39一樣,起始符和結(jié)束符都是*號(hào),你做的條碼掃描不出來的原因,估計(jì)和校驗(yàn)碼有關(guān)。93條碼規(guī)定在數(shù)據(jù)的最后有兩個(gè)校驗(yàn)位C和K,如果你的數(shù)據(jù)里沒有生成這兩個(gè)校驗(yàn)位,那肯定是無法掃描的。
如果是usb掃描槍,是焦點(diǎn)在哪它就輸入在哪,不能自動(dòng)對(duì)應(yīng)到相應(yīng)的文本框
如果是串口掃描槍可以實(shí)現(xiàn)你的功能,在代碼里判斷相應(yīng)的串口對(duì)應(yīng)文本框
你的想法很難實(shí)現(xiàn)。重寫驅(qū)動(dòng)難度相當(dāng)大。
如果我是你的話,我會(huì)和客戶講明難度,并推薦代替方案。
掃描還是用原本驅(qū)動(dòng)進(jìn)行掃描,保存圖片是保存到制定目錄。
開發(fā)的應(yīng)用系統(tǒng)監(jiān)測(cè)制定目錄,并圖本地文件進(jìn)行保存數(shù)據(jù)庫。
這樣就很容易做了。