c# - How does this code work? [HARD] -
link: http://www.codeproject.com/kb/dotnet/twaindotnet.aspx
i'm trying create wrapper class open source .net implementation of twain , i'm having trouble understand how gets image.
i've downloaded source code , in gui there button called acquire. when click button go it's event handler find code assume gets image:
private void menuitemscan_click(object sender, system.eventargs e) { if (!msgfilter) { this.enabled = false; msgfilter = true; application.addmessagefilter(this); } tw.acquire(); }
if follow acquire() method see it's contents, 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 don't understand how method 'void' return type can have return statement. also, acquiring , returning image?
can out?
i'm trying create useful wrapper , open source it, because stands there no easy drag , drop solution scanning images in c#.
thanks help!
edit: regarding returns. til! i'm curious how application gets images display on form.
any guidance?
"void" means returns nothing, not doesn't return. return statement terminates function , returns caller
for other question, there few other relevant stack overflow questions
the dscap line seeing if there multiple images. capture happens part of call dsuserif
Comments
Post a Comment