Modal scan driver dialog

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

Moderator: Alex

Post Reply
DanielLW
Posts: 22
Joined: Tue Sep 01, 2015 2:42 pm

Modal scan driver dialog

Post by DanielLW »

Hello Vintasoft-team,

i've recognized a problem with the scan driver dialogs. I've set the properties "ShowUI" and "ModalUI" of the Vintasoft.Twain.Device to true, but i still can switch between the scan driver UI and the main application windows.

Example code:

Code: Select all

            
            bool bFinished = false;
            Vintasoft.Twain.Device deTest = null;
            Vintasoft.Twain.AcquireModalState amsTest;

            this.dmTest.Open();

            deTest = this.dmTest.DefaultDevice;

            deTest.ShowUI = true;
            deTest.ModalUI = true;
            deTest.ShowIndicators = false;
            deTest.DisableAfterAcquire = false;

            deTest.TransferMode = Vintasoft.Twain.TransferMode.Native;

            deTest.Open();

            deTest.XferCount = -1;
            deTest.DocumentFeeder.Enabled = true;

            // modal acquiring loop
            do
            {
                amsTest = deTest.AcquireModal();

                switch (amsTest)
                {
                    case Vintasoft.Twain.AcquireModalState.ImageAcquired:
                        if (this.pictureBox1.Image != null)
                            this.pictureBox1.Image.Dispose();

                        this.pictureBox1.Image = deTest.AcquiredImage.GetAsBitmap(true);

                        deTest.AcquiredImage.Dispose();

                        break;
                    case Vintasoft.Twain.AcquireModalState.ScanCanceled:
                    case Vintasoft.Twain.AcquireModalState.ScanCompleted:
                    case Vintasoft.Twain.AcquireModalState.ScanFailed:
                    case Vintasoft.Twain.AcquireModalState.UserInterfaceClosed:
                        bFinished = true;
                        break;
                }
            }
            while (!bFinished);

            deTest.Close();

            this.dmTest.Close();
The underlying Vintasoft.Twain.DeviceManager is created with the main application window as parameter in the constructor.

Is this perhaps a known behaviour? Or do i have to call some other method/property to force the twain driver window to be shown as a modal dialog?

Thank you.

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

Re: Modal scan driver dialog

Post by Alex »

Hello Daniel,

SDK just notifies TWAIN driver that modal UI must be used, the further behaviour depends from TWAIN driver. Unfortunately many TWAIN drivers ignore modal flag. In our demos we disable application UI before image scan and enable application UI when scan is finished.

Best regards, Alexander
Post Reply