|
to the post above - awsome code, you saved my life...thank you
|
|
|
|
|
Bug Description:
I have a scanner installed on my computer,but the power supply is turned off.
So when I click the Acquire menuitem of the TWAIN.NET image scanner, an error message is shown.After I clike the OK button on it, the mainform is disabled.
A possible correction:
public enum TwainCommand
{
......
NotDeviceEvent = 5//add another command
}
public TwainCommand PassMessage( ref Message m )
{
......
if( rc==TwRC.Failure )
return TwainCommand.Not;
if( rc == TwRC.NotDSEvent )
return TwainCommand.NotDeviceEvent;
......
}
public TwainCommand PassMessage( ref Message m )
{
......
if (cmd == TwainCommand.Not)
{
Application.RemoveMessageFilter(this);
msgfilter = false;
this.Enabled = true;
this.Activate();
return false;
}
if (cmd == TwainCommand.NotDeviceEvent)
{
this.Enabled = false;
return false;
}
......
}
|
|
|
|
|
its a vb 2005 project, and the workspace is marked private becasue I don't know how to un-mark it as private yet, but it should auto accept your application to join.
http://www.gotdotnet.com/workspaces/workspace.aspx?id=e93d10b6-d8f0-4bc0-affe-0c6549e857d7
gabe
|
|
|
|
|
and now its public (don't have to join) at a new address
http://www.gotdotnet.com/workspaces/workspace.aspx?id=dd75a486-e2da-4547-b475-20739327b376
|
|
|
|
|
HI Anyone can scan multi tiff image?????
Please help.
THX
|
|
|
|
|
In the "Acquire" method in TwainLib.cs change:
TwCapability cap = new TwCapability( TwCap.XferCount, 1 );
to
TwCapability cap = new TwCapability( TwCap.XferCount, -1 );
The last parameter specifies the number of pages to scan.
Felix.
|
|
|
|
|
|
This doesn't seem to work for me.
The scanner GUI closes automatically after scanning the first page.
|
|
|
|
|
" This doesn't seem to work for me.
The scanner GUI closes automatically after scanning the first page. "
is the same for me!!!
someone knows another way?!
Please... need much!
|
|
|
|
|
When i set
TwCapability cap = new TwCapability( TwCap.XferCount, -1 );
i can't stop the scanner when it's running (after click a stop button with command: tw.Finish())
Who can help me,
Thanks and Best regard
--
Nguyen Kiem Hieu
FPT Information System Company
Defense-Sercurity-Education sector
Address: 2nd floor, 101 Lang Ha St, Dongda Dis, Hanoi, Vietnam
Mobile: (+84)0902 216 369
Website: http://www.fis.com.vn
Email: hieunk2@fpt.com.vn
|
|
|
|
|
Hello i need a method for setting tonality and dpi .
example
dpi >= 300
tonality >= X=-100 Y=0
Thanks
|
|
|
|
|
public TwCapability( TwCap cap )
{
Cap = (short) cap;
ConType = -1;
}
public TwCapability( TwCap cap, short sval )
{
Cap = (short) cap;
ConType = (short) TwOn.One;
Handle = Twain.GlobalAlloc( 0x42, 6 );
IntPtr pv = Twain.GlobalLock( Handle );
Marshal.WriteInt16( pv, 0, (short) TwType.Int16 );
Marshal.WriteInt32( pv, 2, (int) sval );
Twain.GlobalUnlock( Handle );
}
TwCapability cap = new TwCapability(TwCap.XferCount,-1);
//rc = GetCapabilityDS( appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Get, cap );
//Pixel Type
cap = new TwCapability(TwCap.IPixelType);
rc = GetCapabilityDS( appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Get, cap );
if (rc==TwRC.Failure)
pixel=true;
i worte this code but it didn't work it gives every time failuare?
why?
Help:---------------
Thanks in advance?
Born to code
|
|
|
|
|
Twain (or my scanner) seems to completely ignore the following code to set the X and Y resolution. I don't get the error messages - but when I look in the Acquire dialog box the resolution is still set to 300 dpi. Any ideas? (Also, most other capability settings fail - I have a Logitech PageScan Color scanner using TWAIN version 1,6,0,6)
<br />
TwCapability cap;<br />
<br />
cap = new TwCapability( TwCap.ICAP_XRESOLUTION, 150 );<br />
rc = DScap( appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap );<br />
if( rc != TwRC.Success )<br />
{<br />
MessageBox.Show("ERROR: X");<br />
CloseSrc();<br />
return false;<br />
}<br />
<br />
<br />
<br />
<br />
cap = new TwCapability( TwCap.ICAP_YRESOLUTION, 150 );<br />
rc = DScap( appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap );<br />
if( rc != TwRC.Success )<br />
{<br />
MessageBox.Show("ERROR: Y");<br />
CloseSrc();<br />
return false;<br />
}
Drew
|
|
|
|
|
Ahhhhh.... I need to set ShowUI to 0! Makes sense - if you show the Acquire dialog, Twain recalls the users last settings.
<br />
TwUserInterface guif = new TwUserInterface();<br />
guif.ShowUI = 0;<br />
guif.ModalUI = 1;<br />
guif.ParentHand = hwnd;<br />
rc = DSuserif( appid, srcds, TwDG.Control, TwDAT.UserInterface, TwMSG.EnableDS, guif );<br />
<br />
if( rc != TwRC.Success )<br />
{<br />
CloseSrc();<br />
return false;<br />
}<br />
Drew
|
|
|
|
|
It is bug in the constructor of TwCapability.
Code before:
public TwCapability( Capability cap, short sval )<br />
{<br />
Cap = (short) cap;<br />
ConType = (short) TwOn.One;<br />
Handle = Twain32API.GlobalAlloc( 0x42, 6 );<br />
IntPtr pv = Twain32API.GlobalLock( Handle );<br />
Marshal.WriteInt16( pv, 0, (short) TwType.Int16); Marshal.WriteInt32( pv, 2, (int) sval );<br />
Twain32API.GlobalUnlock( Handle );<br />
}<br />
<br />
TwCapability cap = new TwCapability(Capability.ICAP_XRESOLUTION, 150);
Look and try this code:
public TwCapability( Capability cap, short sval, TwType type )<br />
{<br />
Cap = (short) cap;<br />
ConType = (short) TwOn.One;<br />
Handle = Twain32API.GlobalAlloc( 0x42, 6 );<br />
IntPtr pv = Twain32API.GlobalLock( Handle );<br />
Marshal.WriteInt16( pv, 0, (short) type ); Marshal.WriteInt32( pv, 2, (int) sval );<br />
Twain32API.GlobalUnlock( Handle );<br />
}<br />
<br />
<br />
TwCapability cap = new TwCapability(Capability.ICAP_XRESOLUTION, 150, TwType.Fix32);
Regards
Bartek Surowiec
|
|
|
|
|
If you are expanding this work like I am,
the TWAIN.h header file is useful:
http://www.twain.org/devfiles/twain.h
Drew
|
|
|
|
|
Hi,
I am trying to set the paper source via code instead of using the Dialog. Any idea how I can do that?
Thanx
Winfried
BTW: Nice code, keep up the good work!
|
|
|
|
|
papersource... like whether to acquire from the flatbed or from the feeder?
check the following caps:
CAP_AUTOFEED
CAP_CLEARPAGE
CAP_FEEDERLOADED
CAP_FEEDPAGE
CAP_REWINDPAGE
and the 'Feeder Control' article in the appendix.
gabe
|
|
|
|
|
Anyone have success getting CustomDsData Set to change the current value of a capability? CustomDsData Get works well (the values for the capabilites match as expected), but after I run the CustomDsData Set passing in a previously saved CustomDsData (and I receive an RC = success), when i recheck a particular capability, the value doesn't match..
gabe
|
|
|
|
|
DAT_SETUPFILEXFER = Access violation writing location ?
Using the twain toolkit, ‘TWAIN_32 Sample Source 1.603’,
CAP_IXferMech has a default of Native
I can set it to File (Windows enviroment) with an RC = Success
CAP_IImageFileFormat has a default of bmp, and I leave it alone as that’s what I’d like
After I receive a TransferReady from the source, I set up a new TW_SETUPFILEXFER
Structure, and pass it into:
Vb.net
DsSetupFileTransfer(pOrigin, pDest, TwDataGroup.Control, _
TwDat.SetupFileXfer, TwMessage.GetDefault, SetupFile)
C#
DsSetupFileTransfer(pOrigin, pDest, TwDataGroup.Control, TwDat.SetupFileXfer, TwMessage.GetDefault, SetupFile);
But I get an “Access violation writing location”
(I get the same message for MSG_SET, MSF_GET, MSG_GETDEFAULT and MSG_RESET.)
In the meantime, the c++ twack32 code seems to transfer in file mode just fine, but seem to be unable to follow its logic
Has anyone ported file transfer to c# or vb.net?
Various defs that I’m using in vb.net and ShardDevelops convertion to c#:
-------------------------------------------------
Vb.net
<dllimport("twain_32.dll", entrypoint:="#1" )=""> _
Private Shared Function DsSetupFileTransfer(ByVal origin As TwIdentity, _
ByVal dest As TwIdentity, _
ByVal dg As TwDataGroup, _
ByVal dat As TwDat, _
ByVal msg As TwMessage, _
ByVal pSetupFile As TwSetupFileXfer) As TwReturnCode
End Function
C# (Sharp develop convertion)
[DllImport("twain_32.dll", EntryPoint = "#1")]
private static TwReturnCode DsSetupFileTransfer(TwIdentity origin, TwIdentity dest, TwDataGroup dg, TwDat dat, TwMessage msg, TwSetupFileXfer pSetupFile)
-------------------------------------------------
vb.net
<structlayout(layoutkind.sequential, pack:="2," charset:="CharSet.Ansi)"> _
Friend Structure TwSetupFileXfer
<marshalas(unmanagedtype.byvaltstr, sizeconst:="256)"> _
Public FileName As String
Public Format As Short
Public VrefNum As Short
End Structure
C# (Sharp develop convertion)
[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)]
internal struct TwSetupFileXfer
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string FileName;
public short Format;
public short VrefNum;
}
-------------------------------------------------
|
|
|
|
|
nevermind.
as is the case, after banging my head on something for a little more than i week - i deciede to ask why i cant get it to work, and within moments after i post the problem makes itself known.
If it matters to anyone else:
replace
ByVal pSetupFile As TwSetupFileXfer
with
ByRef pSetupFile As TwSetupFileXfer
|
|
|
|
|
I have a blog that contains some explanation and code which can be used to transfer a file between a client and a server application, running independently. I have posted the link below, see if it is of any help:
http://haroonalvi.wordpress.com/
|
|
|
|
|
Hai folks, I modified this program depends my requirment. In my code I have 2 form. In the first for I am having button to triger scan from the application. Its properly working. But after scanning number of pages it ll add that to an Image array,and it ll open another form, in that it ll display that images. In this form also I am having a Scan button. If I press this button again it ll triger the scanner and it ll automatically add to the same Image array.
And my problem is, After an hour or more, its displaying an error.
ie " The Image scanner cannot be found. Please check power supply,cable connection,and the scanner is not used by another application.(Code:DS42019)"
I am using FUJITSU Scanner with model DS420. But I could not find the reason.Please help me as soon as posible. Its Very Urgent for me.
You can say may the system is using the scanner. If so,how can I solve that?
-- modified at 9:54 Tuesday 14th February, 2006
|
|
|
|
|
Google. "The image scanner cannot be found"
First Hit.
(http://www.fujitsu.com/global/support/computing/peripheral/scanners/fifaq/install2.html)
Q2. What can I do when the following error messages appear?
A2. ....Is the scanner in ready state?
I bet yours isn't. I bet that after x minutes, the thing goes idle - or you've told it to do something you shouldn't have. Are you checking all your Return & Condition Codes?
If I were you, I'd monitor the Device Events.
If you want more information about device events, read up on the twain 1.9 spec pgs 30, 115, 343, 370 & 503.
After you have read thru the spec on device evetns, if you want some more help on setting that up, post anohter msg here.
|
|
|
|
|
hi, i am trying to scan without showing the UI but i cannot change the area which i want to scan does anybody know how to do it? (is it posible to set the twDat imagelayout)
|
|
|
|
|