Page 1 of 1

Losing Window Focus

Posted: Wed Jun 26, 2019 4:40 pm
by mrnate
Hello,

I am using the sample code, specifically the AcquireImageModal routine, and my application loses focus after acquiring an image.

I am activating the main form after the image is acquired, but it still results in a * window (losing focus, then activating)

Is there something that can be done to remedy this behavior?



Thanks,
Nate

Re: Losing Window Focus

Posted: Wed Jun 26, 2019 4:56 pm
by Alex
Hello Nate,

What TWAIN driver do you use?

Best regards, Alexander

Re: Losing Window Focus

Posted: Wed Jun 26, 2019 5:10 pm
by mrnate
I'm using the 32bit CanoScan 9000F Mark II driver

Re: Losing Window Focus

Posted: Wed Jun 26, 2019 5:20 pm
by mrnate
aha, I figured out the culprit.

I am disabling the form (effectively disabling all the controls) and then re-enabling the form before/after the image acquisition. That must be messing with the Window handle being passed to the TWAIN driver?

Once I remove that, everything works as expected.

Thanks!

Re: Losing Window Focus

Posted: Wed Jun 26, 2019 5:42 pm
by Alex
Thank you for information.

How do you initialize instance of DeviceManager class? Do you pass the WinForm object or windows handle to the constructor of DeviceManager class?
Please pass information about parent window to the constructor of DeviceManager class and this also may solve the problem.

Best regards, Alexander

Re: Losing Window Focus

Posted: Wed Jun 26, 2019 5:53 pm
by mrnate
using (DeviceManager deviceManager = new DeviceManager(this))

Re: Losing Window Focus

Posted: Wed Jun 26, 2019 8:18 pm
by Alex
mrnate wrote: Wed Jun 26, 2019 5:53 pm using (DeviceManager deviceManager = new DeviceManager(this))
This is correct code. I think your solution with disabling/enabling UI is the best solution for your TWAIN driver.

Best regards, Alexander