TWAIN Working Group

Newsletter Signup
Donate
Help keep TWAIN free
  • About TWAIN
    • What’s New?
    • News
    • Events
    • Membership
    • Consider a Donation
    • Contact Us
  • Why TWAIN?
  • Developers
    • Driver Developer
    • Application Developer
    • TWAIN Features
    • Specification & Tools
    • Self Certification Process
  • Support Forums
  • Scanner End-User
  • Find Certified Drivers
    • Facebook
    • LinkedIn
    • Vimeo

TWAIN for C# Question

Forums › TWAIN Classic › TWAIN for C# Question

  • This topic has 4 replies, 3 voices, and was last updated 4 years, 10 months ago by tickies.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • February 16, 2016 at 10:20 pm #23055 Reply
    shekharsh
    Participant
    • Topics - 2
    • Replies - 3
    • Total Posts - 5

    I am working with the code samples for the TWAIN for C# Project (https://sourceforge.net/projects/twainforcsharp/).

    I am looking for sample code to change scanner settings programmatically. For example, I am looking for some code samples to not show the Twain Driver window and use scan type of ADF Duplex without any user input. How can this be accomplished?

    Thanks in advance for your help.

    February 17, 2016 at 6:00 pm #26378 Reply
    MarkM
    Participant
    • Topics - 1
    • Replies - 135
    • Total Posts - 136

    The TWAIN C# project comes with two applications. One is a diagnostic application. The other is a regular scanning application, and is designed to show how one can write a C# application to interface to the TWAIN C# toolkit.

    The built-in toolkit attempts to make coding easier by moving the image transfer code into a callback. The application starts scanning, and the callback processes images, metadata and status returns.

    As for communication, the toolkit does this using CSV strings. This was done to take away the pain of having C# marshal to C/C++ data structures.

    Here is how to turn on duplex scanning. You can find this code similar to this in: TWAIN CS 02.03.02.00twaincssourcetwaincsscansourceFormScan.cs
    string szStatus = “”;
    string szCapability = “CAP_DUPLEXENABLED,TWON_ONEVALUE,TWTY_BOOL,1”;
    TWAINCSToolkit.STS sts = m_twaincstoolkit.Send(“DG_CONTROL”, “DAT_CAPABILITY”, “MSG_SET”, ref szCapability, ref szStatus);
    Be sure to confirm that the status is success, in case the scanner doesn’t support duplex.

    This is the command sent to start scanning. You can find this code in: TWAIN CS 02.03.02.00twaincssourcetwaincsscansourceFormScan.cs
    string szStatus = “”;
    string szTwmemref = “0,0,” + this.Handle;
    TWAINCSToolkit.STS sts = m_twaincstoolkit.Send(“DG_CONTROL”, “DAT_USERINTERFACE”, “MSG_ENABLEDS”, ref szTwmemref, ref szStatus);

    The contents of szTwmemref are a CSV encoded version of the TW_USERINTERFACE structure described in the TWAIN Specification and found in the C/C++ TWAIN.H file.

    Note that this CSV scheme can be used with the diagnostic application, so that’s a good tool for experimenting with a driver to see how it all works.

    February 17, 2016 at 6:19 pm #26379 Reply
    shekharsh
    Participant
    • Topics - 2
    • Replies - 3
    • Total Posts - 5

    Thanks @MarkM. Great answer. Is there a way to programmatically suppress the scanner device driver messagebox that pops up?

    February 17, 2016 at 6:21 pm #26380 Reply
    shekharsh
    Participant
    • Topics - 2
    • Replies - 3
    • Total Posts - 5

    Sorry I replied too early. It seems like this code will suppress the message box.

    This is the command sent to start scanning. You can find this code in: TWAIN CS 02.03.02.00twaincssourcetwaincsscansourceFormScan.cs
    string szStatus = “”;
    string szTwmemref = “0,0,” + this.Handle;
    TWAINCSToolkit.STS sts = m_twaincstoolkit.Send(“DG_CONTROL”, “DAT_USERINTERFACE”, “MSG_ENABLEDS”, ref szTwmemref, ref szStatus);

    I will try this out.

    Thanks for your help.

    March 22, 2016 at 2:10 pm #26381 Reply
    tickies
    Participant
    • Topics - 2
    • Replies - 2
    • Total Posts - 4

    Hello,

    I have the same problem as shekharsh described in the text above. I would like to suppress all message boxes.

    Further information:
    I am also working with the code samples for the TWAIN for C# Project (https://sourceforge.net/projects/twainforcsharp/).

    I start scanning with this:
    TWAINCSToolkit.STS sts = m_twaincstoolkit.Send(“DG_CONTROL”, “DAT_USERINTERFACE”, “MSG_ENABLEDS”, ref szTwmemref, ref szStatus);

    but it still does not work. Could anybody help here?

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: TWAIN for C# Question
Your information:




Quick Links

Service Providers
TWAIN Support Forums
Membership
Contact Us
Privacy Policy

Newsletter Signup

TWAIN Working Group Family

TWAIN Working Group
TWAIN Direct®
TWAIN Resources
TWAIN Certified Drivers
PDF/raster

  • Facebook
  • GitHub
  • LinkedIn
  • Vimeo

Recent Topics

  • EPSON V600 TWAIN and WIA on Windows 10
  • When and how to use WaitForEvents command ?
  • Problem enumerating list of installed scanners in windows server 2012
  • Failed to create TWAIN progress! Error code is 1260.
  • To get the list of scanners from javascript client side (browser)
  • Quarterly Newsletter
  • TWAIN Working Group Membership
  • Logo Usage
  • TWAIN License
  • Contact Us
Privacy Policy • Privacy Tools • Copyright © 2021 TWAIN Working Group • by iHwy, LLC • Log in

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.