'扫描事件
Public Sub LinkLabel1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim frm As WinForm.Form = Forms("图片管理器")
Dim piv As WinForm.PictureViewer = Forms("图片管理器").Controls("PictureViewer1")
Dim imageFile As WIA.imageFile
Dim cdc As New WIA.CommonDialogClass()
Try
imageFile = cdc.ShowAcquireImage(WIA.WiaDeviceType.ScannerDeviceType, WIA.WiaImageIntent.TextIntent, WIA.WiaImageBias.MaximizeQuality, "{00000000-0000-0000-0000-000000000000}", True, True,False)
If imageFile IsNot Nothing Then
'Dim path As String = ProjectPath & "Attachments\sm" & Format(Date.Now,"yyyyMMddHHmmss") & ".jpg"
'-----------------------------------
Dim ary = piv.BindingField.split(".") '有点甜改扫描存放地址
Dim str As String = Tables(ary(0)).DataTable.DataCols(ary(1)).DefaultFolder
str = iif(str = "", projectPath & "attachments", str)
Dim path As String = str & "\sm" & Format(Date.Now,"yyyyMMddHHmmss") & ".jpg"
'-----------------------------------
imageFile.SaveFile(path)
piv.AddFile(FileSys.GetName(path))
End If
Catch generatedExceptionName As System.Runtime.InteropServices.COMException
MessageBox.Show("您的扫描仪尚未准备好!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error)
End Try
End Sub
2、扫描仪窗口afterload,设置了绑定字段:
Dim pbx As WinForm.PictureViewer '图片浏览器绑定窗口表列
pbx = Forms("图片管理器").Controls("PictureViewer1")
pbx.BindingField = "扫描仪_Table1.扫描图片"