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

Windowless TWAIN session shutdown errors

Forums › TWAIN Classic › Windowless TWAIN session shutdown errors

  • This topic has 2 replies, 3 voices, and was last updated 7 years, 10 months ago by dpenney.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • February 27, 2013 at 4:03 pm #22827 Reply
    theck01
    Participant
    • Topics - 1
    • Replies - 0
    • Total Posts - 1

    Hi everyone,

    I’m currently writing an application that interfaces with a Leica microscopy camera on Windows XP, and things have been going smoothly so far. The application is a simple web server that allows the microscope to be controlled from a different location. Because the application is a web server I have been preventing the TWAIN session from opening any windows and have set the hParent field of TW_USERINTERFACE to NULL when enabling the data source. The webserver has no window of its own, so there is nothing that I can set hParent to that will make sense.

    Things work well until I attempt to shut the server down. At this point the data source cannot be disabled, and neither the data source or the data source manager can be closed successfully. From my experimentation I believe that this is due to the NULL value I gave to the hParent field of TW_USERINTERFACE. Is there a value that I should be giving the hParent field besides NULL for a windowless application? And does anyone have other ideas about why the source and source manager refuse to close, even if all I do is start open them, enable the source, and then immediately attempt to disable and close?

    Thanks

    March 5, 2013 at 8:27 pm #25820 Reply
    spike
    Participant
    • Topics - 10
    • Replies - 139
    • Total Posts - 149

    Hi Theck01 –
    It is not surprising that TWAIN or the Leica driver don’t work quite right when hParent = NULL, as the TWAIN specification does not allow for this possibility, or define the behavior of TWAIN in this case. What is surprising is that the Leica driver works at all in this situation 😮

    Are you intercepting messages in the message pump and forwarding them via MSG_PROCESSEVENT? And is your app receiving MSG_XFERREADY messages?

    I’d suggest creating an invisible ‘proxy’ window and passing its handle in hParent. Destroy it after MSG_CLOSEDS is completed.

    March 7, 2013 at 5:44 pm #25821 Reply
    dpenney
    Participant
    • Topics - 3
    • Replies - 66
    • Total Posts - 69

    Even when an application sets ShowUI to false on MSG_ENABLEDS and CAP_INDICATORS to false, the DS may show UI. To see how it can do that while still be compliant with the specification, please read the section “Error and Device Control Indicators” in the TWAIN specification.

    If that’s not a show stopper your webserver should create an window (as spike suggested) or call GetDesktopWindow() to get a valid HWND to use as the parent window. Note that if the webserver is a Windows service it should not call TWAIN since it may need to display UI.

    @theck01 wrote:

    Hi everyone,

    I’m currently writing an application that interfaces with a Leica microscopy camera on Windows XP, and things have been going smoothly so far. The application is a simple web server that allows the microscope to be controlled from a different location. Because the application is a web server I have been preventing the TWAIN session from opening any windows and have set the hParent field of TW_USERINTERFACE to NULL when enabling the data source. The webserver has no window of its own, so there is nothing that I can set hParent to that will make sense.

    Things work well until I attempt to shut the server down. At this point the data source cannot be disabled, and neither the data source or the data source manager can be closed successfully. From my experimentation I believe that this is due to the NULL value I gave to the hParent field of TW_USERINTERFACE. Is there a value that I should be giving the hParent field besides NULL for a windowless application? And does anyone have other ideas about why the source and source manager refuse to close, even if all I do is start open them, enable the source, and then immediately attempt to disable and close?

    Thanks

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: Windowless TWAIN session shutdown errors
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.