Scanning from within a Visual Basic project

  • Thread starter Thread starter Dave Froble
  • Start date Start date
D

Dave Froble

I tried looking in the archives, but I'm rather poor at searching, so
I'll ask. The subject pretty much describes my question. I want to
scan from within a VB project, and don't have any idea where to begin.
Any and all help would be appriciated.

--
David Froble Tel: 724-529-0450
Dave Froble Enterprises, Inc. Fax: 724-529-0596
DFE Ultralights, Inc. E-Mail: (e-mail address removed)
170 Grimplin Road
Vanderbilt, PA 15486
 
Dave Froble said:
I tried looking in the archives, but I'm rather poor at searching, so I'll
ask. The subject pretty much describes my question. I want to scan from
within a VB project, and don't have any idea where to begin. Any and all
help would be appriciated.

--
David Froble Tel: 724-529-0450
Dave Froble Enterprises, Inc. Fax: 724-529-0596
DFE Ultralights, Inc. E-Mail: (e-mail address removed)
170 Grimplin Road
Vanderbilt, PA 15486

Have you looked at the programming at twain.org? (Click Downloads)
http://twain.org/

Check the FAQ: (Click FAQ on the left)
Question: Is it possible to write a Windows TWAIN Application using Visual
Basic or other high level programming language that doesn't allow modifying
the main application's message loop?
 
Have you looked at the programming at twain.org? (Click Downloads)
http://twain.org/

Check the FAQ: (Click FAQ on the left)
Question: Is it possible to write a Windows TWAIN Application using Visual
Basic or other high level programming language that doesn't allow modifying
the main application's message loop?

Another way is to use an OCX. Apparently many versions of Windows have
one included. On my system here I have one by Kodak called IMGSCAN.OCX
officially described in Project/Components as "Kodak Image Scan
Control". However, it works with all TWAIN devices installed on my
system (flatbed scanner, film scanner, various digicams, etc).
However, it only provides a very basic scanner support.

As CSM1 says, it's far better to directly access the TWAIN module
supplied by your scanner manufacturer. The drawbacks are that you will
probably need the SDK (software developer kit) to make full use of it
and the interface is usually geared towards C which means having to
write "wrapper code" so VB can talk to it. On the plus side you will
then be able to use all additional features unique to your scanner
which may not be a part of standard TWAIN specifications.

Don.
 
Don said:
Another way is to use an OCX. Apparently many versions of Windows have
one included. On my system here I have one by Kodak called IMGSCAN.OCX
officially described in Project/Components as "Kodak Image Scan
Control". However, it works with all TWAIN devices installed on my
system (flatbed scanner, film scanner, various digicams, etc).
However, it only provides a very basic scanner support.

As CSM1 says, it's far better to directly access the TWAIN module
supplied by your scanner manufacturer. The drawbacks are that you will
probably need the SDK (software developer kit) to make full use of it
and the interface is usually geared towards C which means having to
write "wrapper code" so VB can talk to it. On the plus side you will
then be able to use all additional features unique to your scanner
which may not be a part of standard TWAIN specifications.

Don.

I'll take a look at the Kodak control. I don't need anything fancy.
The applications is thus. Certain documents on 8.5 x 11 paper need to
be scanned and placed into files. A database record is created to point
to the file. Thus, a user can pull up and view any documents associated
with a transaction. Plain black & white images are totally adequate.

Thanks for the tip.

A quick google search revealed that there are vendors with twain
controls. Haven't had a chance to look at any yet.

--
David Froble Tel: 724-529-0450
Dave Froble Enterprises, Inc. Fax: 724-529-0596
DFE Ultralights, Inc. E-Mail: (e-mail address removed)
170 Grimplin Road
Vanderbilt, PA 15486
 
....
I'll take a look at the Kodak control. I don't need anything fancy.
The applications is thus. Certain documents on 8.5 x 11 paper need to
be scanned and placed into files. A database record is created to point
to the file. Thus, a user can pull up and view any documents associated
with a transaction. Plain black & white images are totally adequate.

In that case an OCX will be more than adequate. For example to show
available TWAIN devices with the Kodak one all you do is:

ImgScan1.ShowSelectScanner

This pops-up a list box will all installed TWAIN drivers highlighting
the one currently selected.

Other functions are similar one-liners and it's all explained in the
help files.
Thanks for the tip.

You're most welcome. Good luck!
A quick google search revealed that there are vendors with twain
controls. Haven't had a chance to look at any yet.

If the customer/employer pays for it, then why not? ;o)

Don.
 
Don said:
In that case an OCX will be more than adequate. For example to show
available TWAIN devices with the Kodak one all you do is:

ImgScan1.ShowSelectScanner

This pops-up a list box will all installed TWAIN drivers highlighting
the one currently selected.

Other functions are similar one-liners and it's all explained in the
help files.

At the risk of appearing lazy, though I did look, where can I find the
mentioned help files?

I'm trying to test the Kodak IMGSCAN and the properties are not
intuitive to someone who has never worked with scanners before.

You mention the OCX working for you. Do you have any examples, mainly
how you set up the properties, and when. I'm assuming a command button
to set properties, open the scanner, and whatever else is required. In
one test, it appeared that opening the scanner (not one on development
system) popped up a dialogue box that included a command button to start
scanning. All details appriciated.

--
David Froble Tel: 724-529-0450
Dave Froble Enterprises, Inc. Fax: 724-529-0596
DFE Ultralights, Inc. E-Mail: (e-mail address removed)
170 Grimplin Road
Vanderbilt, PA 15486
 
At the risk of appearing lazy, though I did look, where can I find the
mentioned help files?

Good question! ;o) It's been a while... Let's see... It's called
"Imaging Controls Help" and I suspect it's hiding together with other
VB help files (I installed them all).

Here's a quick and dirty method to invoke it. Type any of its
properties anywhere in your code, for example:

ShowSelectScanner

Highlight this (double-click on it) and them press F1. This invokes
the relevant help file and then you can go to the Index, etc.

Try that, and if it doesn't work, then I'll have a closer look.
I'm trying to test the Kodak IMGSCAN and the properties are not
intuitive to someone who has never worked with scanners before.

You mention the OCX working for you. Do you have any examples, mainly
how you set up the properties, and when. I'm assuming a command button
to set properties, open the scanner, and whatever else is required. In
one test, it appeared that opening the scanner (not one on development
system) popped up a dialogue box that included a command button to start
scanning. All details appriciated.

I just ran through most of the options to see what they do. As I say I
was just fooling around (I ended up writing my own scanner program).

Anyway, after including the OCX, add it to your project. You can then
explore the properties with the usual Right-Click/Properties.

For the rest, I'll include my code below. It's not much... I basically
added a button for each function and also a text box for each display.
These text boxes are populated in Form_Load.

Don.

--- start ---

Private Sub Form_Load()
txtDIC = ImgScan1.DestImageControl
txtFC = ImgScan1.FileType
txtImage = ImgScan1.Image
txtMP = ImgScan1.MultiPage
txtPage = ImgScan1.Page
txtPC = ImgScan1.PageCount
txtPO = ImgScan1.PageOption
txtST = ImgScan1.ScanTo
txtScroll = ImgScan1.Scroll
txtSSBS = ImgScan1.ShowSetupBeforeScan
txtStatus = ImgScan1.StatusCode
txtSSB = ImgScan1.StopScanBox
txtZoom = ImgScan1.Zoom
...

---

Private Sub cmdAbout_Click()
ImgScan1.AboutBox
End Sub

Private Sub cmdScanner_Click()
On Error Resume Next
ImgScan1.ShowSelectScanner
'MsgBox Err.Number & ": " & Err.Description
On Error GoTo 0
End Sub

Private Sub cmdScanNew_Click()
ImgScan1.ShowScanNew
End Sub

Private Sub cmdScanPage_Click()
ImgScan1.ShowScanPage
End Sub

Private Sub cmdScanPrefs_Click()
ImgScan1.ShowScanPreferences
End Sub

Private Sub cmdOpenScan_Click()
ImgScan1.OpenScanner
End Sub

Private Sub cmdResetScan_Click()
ImgScan1.ResetScanner
End Sub

Private Sub cmdCloseScan_Click()
ImgScan1.CloseScanner
End Sub

Private Sub cmdStartScan_Click()
ImgScan1.StartScan
End Sub

Private Sub cmdStopScan_Click()
ImgScan1.StopScan
End Sub

Private Sub cmdAvailTWAIN_Click()
If ImgScan1.ScannerAvailable Then
i = MsgBox("Scanner TWAIN software is available", vbOKOnly +
vbExclamation)
Else
i = MsgBox("Scanner TWAIN software is *NOT* available", vbOKOnly
+ vbCritical)
End If
End Sub

--- end ---
 
Don said:
For the rest, I'll include my code below. It's not much... I basically
added a button for each function and also a text box for each display.
These text boxes are populated in Form_Load.

Thanks. Looks like I'll be digging into things for a while.

--
David Froble Tel: 724-529-0450
Dave Froble Enterprises, Inc. Fax: 724-529-0596
DFE Ultralights, Inc. E-Mail: (e-mail address removed)
170 Grimplin Road
Vanderbilt, PA 15486
 
Back
Top