Page 1 of 1

Do scanner setting by Twain GUI (CustomDsData)

Posted: Wed Jan 04, 2023 5:30 pm
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

Re: Do scanner setting by Twain GUI (CustomDsData)

Posted: Fri Jan 06, 2023 12:48 pm
by Alex
Hi Hans,

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

Best regards, Alexander

Re: Do scanner setting by Twain GUI (CustomDsData)

Posted: Mon Jan 09, 2023 8:12 pm
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

Re: Do scanner setting by Twain GUI (CustomDsData)

Posted: Tue Jan 10, 2023 8:48 am
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

Re: Do scanner setting by Twain GUI (CustomDsData)

Posted: Tue Jan 10, 2023 12:58 pm
by Hans7711
Hi Alex,

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

Kind regards, Hans

Re: Do scanner setting by Twain GUI (CustomDsData)

Posted: Wed Jan 11, 2023 8:53 am
by Alex
Hi Hans,

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

Best regards, Alexander

Re: Do scanner setting by Twain GUI (CustomDsData)

Posted: Wed Jan 11, 2023 7:11 pm
by Hans7711
Thanks, Alex!