If I just do a me.visible=false and then go back in it works fine
Any ideas on why this is happening?
How to reproduce your problem ? The information you gave are not sufficient for investigation.
Maybe you have to unload the TWAIN source manager before calling "me.close" ? See method TwainUnloadSourceManager.
I just took your twain sample and created a new form (form2) with two buttons (One scan and one return), Then I copied all of your code from behind the scan all document feeder (adf) into jpeg files and pasted that behind the scan button on form2. I also commented out the initscanconfig, applyimagefilters and check preview routines. Behind the return button I have a me.close and I also make form1.visible=true
When I click the scan button (I created) on form2 the first time it scans all documents fine, then I press the return button to return to the first screen. If I try to go to form2 again to scan, It either just sits at the scanner screen or gives me a error that it cannot connect to the scanner.
Below is the code behind the scan button on form 2, Behind the return button is only me.close and form1.visible=true
'Here we will scan in a 24bpp & 300 DPI from ADF into separate jpeg files
Dim nImageCount As Integer
Dim ImageID As Integer
Dim oGdPictureImaging As New GdPictureImaging
If oGdPictureImaging.TwainOpenDefaultSource(Me.Handle) Then
nImageCount = 0
oGdPictureImaging.TwainSetAutoFeed(True) 'Set AutoFeed Enabled
oGdPictureImaging.TwainSetAutoScan(True) 'To achieve the maximum scanning rate
oGdPictureImaging.TwainSetBitDepth(8) ' 24 bpp
ImageID = oGdPictureImaging.TwainAcquireToGdPictureImage(Me.Handle)
If ImageID <> 0 Then
'If chkPreview.CheckState = 1 Then Call DisplayImage(ImageID)
nImageCount = nImageCount + 1
Call oGdPictureImaging.SaveAsJPEG(ImageID, My.Application.Info.DirectoryPath & "\image" & Trim(Str(nImageCount)) & ".jpg", 75)
Loop While oGdPictureImaging.TwainGetState > TwainStatus.TWAIN_SOURCE_ENABLED
MsgBox("can't open default source, twain state is: " & oGdPictureImaging.TwainGetState.ToString)
Thanks for your help
Who is online
Users browsing this forum: Bing [Bot] and 2 guests