ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 How to handle disconnected scanner
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Homer

USA
70 Posts

Posted - Jan 05 2022 :  18:56:13  Show Profile  Reply
I disconnected my scanner's USB cable to emulate a missing or disconnected scanner. This code causes the following message. That message appears to be from my scanner's driver. The line of code is the first attempt to communicate with the scanner. It's done as the main form opens.
ImageEnMView1.MIO.AcquireParams.DuplexEnabled;

Is there a way to trap the appearance of this warning so that my code can behave accordingly. If not, I need to know how to see if there are any connected devices. I've tried putting this in a try/except block, but it doesn't actually throw an exception.



BTW, I execute that line of code because I learned that calling AcquireParams once, where it won't be noticed, makes all subsequent calls much faster. I don't do anything with the return value. Its only purpose is to speed up the opening of my homemade scanner dialog.

Homer

USA
70 Posts

Posted - Jan 06 2022 :  11:35:18  Show Profile  Reply
Is this a good solution? I set a global boolean variable based on the AcquireParams.PhysicalWidthPixels return value. My assumption is, it should always be > 0. My concern is, what happens if a scanner is on and connected, but simply doesn't return this value?

I've tried this, and it works with my HP scanner.
gbScannerAvailable := ImageEnMView1.MIO.AcquireParams.PhysicalWidthPixels > 0 ;



But this looks better.
gbScannerAvailable := ImageEnView1.IO.TwainParams.DeviceOnline;


Anyone with experience trapping a disconnected scanner or one that is off?
Go to Top of Page

xequte

38222 Posts

Posted - Jan 07 2022 :  00:21:10  Show Profile  Reply
Hi

Generally DeviceOnline should be the correct one to use, but it is only available for Twain devices so you would need to ensure SelectedAcquireSource.Api is ieaTwain

https://www.imageen.com/help/TImageEnIO.SelectedAcquireSource.html

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Homer

USA
70 Posts

Posted - Jan 07 2022 :  00:50:09  Show Profile  Reply
Thanks. I thought that was it.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: