LINK: http://www.codeproject.com/KB/dotnet/twaindotnet.aspx
I'm trying to create a wrapper class for this open source .NET implementation of TWAIN and I'm having trouble understand how it actually gets the image.
I've downloaded the source code and in the GUI there is a button called Acquire. When I click this button to go to it's event handler I find this code which I assume gets the image:
private void menuItemScan_Click(object sender, System.EventArgs e)
{
if (!msgfilter)
{
this.Enabled = false;
msgfilter = true;
Application.AddMessageFilter(this);
}
tw.Acquire();
}
If I follow the Acquire() method to see it's contents, I see this:
public void Acquire()
{
TwRC rc;
CloseSrc();
if (appid.Id == IntPtr.Zero)
{
Init(hwnd);
if (appid.Id == IntPtr.Zero)
return;
}
rc = DSMident(appid, IntPtr.Zero, TwDG.Control, TwDAT.Identity, TwMSG.OpenDS, srcds);
if (rc != TwRC.Success)
return;
TwCapability cap = new TwCapability(TwCap.XferCount, 1);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap);
if (rc != TwRC.Success)
{
CloseSrc();
return;
}
TwUserInterface guif = new TwUserInterface();
guif.ShowUI = 1;
guif.ModalUI = 1;
guif.ParentHand = hwnd;
rc = DSuserif(appid, srcds, TwDG.Control, TwDAT.UserInterface, TwMSG.EnableDS, guif);
if (rc != TwRC.Success)
{
CloseSrc();
return;
}
}
What I don't understand is how a method with a 'void' return type can actually have a return statement. Also, where is it acquiring and returning an image?
Can anyone help out?
I'm trying to create a useful wrapper and open source it, because as it stands there is no easy drag and drop solution for scanning images in C#.
Thanks for the help!
Edit: Thanks for the help regarding early returns. TIL! Now I'm curious about how the application gets the images to display on the form.
Any guidance?