Do scanner setting by Twain GUI (CustomDsData)

Questions, comments and suggestions concerning VintaSoft Twain .NET SDK.

Moderator: Alex

Post Reply
Hans7711
Posts: 5
Joined: Wed Jan 04, 2023 4:57 pm

Do scanner setting by Twain GUI (CustomDsData)

Post by Hans7711 »

Hi, I'm new here and evaluating the VB.NET Twain SDK for Kodak i5850.

we would like to scan jobwise an load twain settings from file. To adjust the scanjobs, we want to use the GUI of the twain driver in that way:

1. device.LoadSettings(fs) 'loading the scanner settings from file
2. <adjust by GUI>
3. device.SaveSettings(fs) 'save the new scanner setting to file

Actually I cannot find a method to call the Twain UI without scanning (only to adjust). I know from another scan software the this is possible for this scanner and twain driver.

Thank you very much.

Sincerely, Hans
Alex
Site Admin
Posts: 2305
Joined: Thu Jul 10, 2008 2:21 pm

Re: Do scanner setting by Twain GUI (CustomDsData)

Post by Alex »

Hi Hans,

If you want to change the device settings only, you need to use the Device.ShowSetupDialog method.

Best regards, Alexander
Hans7711
Posts: 5
Joined: Wed Jan 04, 2023 4:57 pm

Re: Do scanner setting by Twain GUI (CustomDsData)

Post by Hans7711 »

Hi Alex,

thank you very much for your information. Loading the settings works fine:

device.Open()
LoadSettings("C:\_Share\Source\_NET\VintaSoft\Patch2_i5850.twn", device)
device.ShowSetupDialog() 'to adjust some new settings

but saving the new settings does not work, obiously because the device is closed by ShowSetupDialog(),
SaveSettings(device, "C:\_Share\Source\_NET\VintaSoft\Patch2_i5850_out.twn")
device.Close()

When reopening the device an saving then, the adjstments made in ShowSetupDialog() are not present in the new file "Patch2_i5850_out.twn", There seems to be default settings. What can I do do preserve / save the Settings?

Sincerely, Hans


Public Sub LoadSettings(ByVal sFile As String, ByVal device As Vintasoft.Twain.Device)
Using fs As New IO.FileStream(sFile, IO.FileMode.Open, IO.FileAccess.Read)
device.LoadSettings(fs)
End Using
End Sub

Public Sub SaveSettings(ByVal device As Vintasoft.Twain.Device, ByVal sFile As String)
Using fs As New System.IO.FileStream(sFile, System.IO.FileMode.Append, System.IO.FileAccess.Write)
device.SaveSettings(fs)
End Using
End Sub
Alex
Site Admin
Posts: 2305
Joined: Thu Jul 10, 2008 2:21 pm

Re: Do scanner setting by Twain GUI (CustomDsData)

Post by Alex »

Hi Hans,

After calling the Device.ShowSetupDialog method you need wait for Device.UserInterfaceClosed event and close/disable the device in the event handler if this necessary. Please save settings and close the device in handler of Device.UserInterfaceClosed event.

Best regards, Alexander
Hans7711
Posts: 5
Joined: Wed Jan 04, 2023 4:57 pm

Re: Do scanner setting by Twain GUI (CustomDsData)

Post by Hans7711 »

Hi Alex,

thank you again, I forgot to disable the device. How can I see if ShowSetupDialog was cancelled?

Kind regards, Hans
Alex
Site Admin
Posts: 2305
Joined: Thu Jul 10, 2008 2:21 pm

Re: Do scanner setting by Twain GUI (CustomDsData)

Post by Alex »

Hi Hans,

TWAIN specification does not allow to determine if "OK" or "Cancel" button is clicked in TWAIN GUI.

Best regards, Alexander
Hans7711
Posts: 5
Joined: Wed Jan 04, 2023 4:57 pm

Re: Do scanner setting by Twain GUI (CustomDsData)

Post by Hans7711 »

Thanks, Alex!
Post Reply