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?


9 Years
Discussion Span
Last Post by LizR

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 });

Edited by Reverend Jim: Fixed formatting


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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.