Hi all,

I have a C# (VS 2005) program using a Twain dll of Atalasoft, to connect to a scanner.
When a fast scanner saves the files to disk, I show them in a PictureBox on the screen.
This goes all well while nothing else happens. When I click on a button of the window, or when an other window gets the focus, my program doesn's show the pictures anymore, although the communication with the scanner works fine.
I allready used the Refresh() to display the pictures, but that doesn't help.

Is there anyone who can halp me?


Have you tried debugging to see what's going on?

Depends how you show them in the picture box at a guess..

each time the scanner has a page scanned, an event is fired and I give the name of the file to save and remember that filename in a list.
I also load the latest saved file in my picture, when it is available on disk.
After that a call a Refresh of the form.
I think the event is fired from another thread.

Thank you for your reply.

The way I load the pictures gives on several ways the same problem:

plaatjes[numbers[i]].Image = Image.FromFile(bestanden[NrBestand - terug]);

or using a ImageFast.FastFromFile:

[DllImport("gdiplus.dll", CharSet = CharSet.Unicode)]
    public static extern int GdipLoadImageFromFile(string filename, out IntPtr image);

    private ImageFast1()

    private static Type imageType = typeof(System.Drawing.Bitmap);

    public static Image FastFromFile(string filename)
        filename = Path.GetFullPath(filename);
        IntPtr loadingImage = IntPtr.Zero;

        // We are not using ICM at all, fudge that, this should be FAAAAAST!
        if (GdipLoadImageFromFile(filename, out loadingImage) != 0)
            throw new Exception("GDI+ threw a status error code.");
        return (Bitmap)imageType.InvokeMember("FromGDIplus", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.InvokeMethod, null, null, new object[] { loadingImage });

if you're loading a bitmap image, why not just ask the picturebox to load the image?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.