Leadtools TWAIN (Leadtools.Twain assembly)
LEAD Technologies, Inc

SetCodeMessage Method

Example 





A TwainExceptionCode value to set the string message for.
A System.String that contains the new message for code.
Sets the error string that corresponds to a specific TwainExceptionCode
Syntax
public static void SetCodeMessage( 
   TwainExceptionCode code,
   string message
)
'Declaration
 
Public Shared Sub SetCodeMessage( _
   ByVal code As TwainExceptionCode, _
   ByVal message As String _
) 
'Usage
 
Dim code As TwainExceptionCode
Dim message As String
 
TwainException.SetCodeMessage(code, message)
public static void SetCodeMessage( 
   TwainExceptionCode code,
   string message
)
 function Leadtools.Twain.TwainException.SetCodeMessage( 
   code ,
   message 
)
public:
static void SetCodeMessage( 
   TwainExceptionCode code,
   String^ message
) 

Parameters

code
A TwainExceptionCode value to set the string message for.
message
A System.String that contains the new message for code.
Remarks
By default, TwainException has a string message for each TwainExceptionCode. You can get this message by using the GetCodeMessage method. Also, you can change any string message for any TwainExceptionCode by using the SetCodeMessage method.
Example
 
Public Sub SetCodeMessageExample()
   ' Get the initial FileFormat message
   Dim code As TwainExceptionCode = TwainExceptionCode.StopScan
   Dim message As String = TwainException.GetCodeMessage(code)
   MessageBox.Show(String.Format("Code: {0}, message: {1}", code, message))

   ' make sure that this message is used now
   Try
      Throw New TwainException(code)
   Catch ex As Exception
      MessageBox.Show(ex.Message)
   End Try

   ' change this message to a custom one
   TwainException.SetCodeMessage(code, "My new message")

   ' make sure that this new message is used now
   Try
      Throw New TwainException(code)
   Catch ex As Exception
      MessageBox.Show(ex.Message)
   End Try
End Sub
public void SetCodeMessageExample()
{
   // Get the initial FileFormat message
   TwainExceptionCode code = TwainExceptionCode.StopScan;
   string message = TwainException.GetCodeMessage(code);
   MessageBox.Show(string.Format("Code: {0}, message: {1}", code, message));

   // make sure that this message is used now
   try
   {
      throw new TwainException(code);
   }
   catch(Exception ex)
   {
      MessageBox.Show(ex.Message);
   }

   // change this message to a custom one
   TwainException.SetCodeMessage(code, "My new message");

   // make sure that this new message is used now
   try
   {
      throw new TwainException(code);
   }
   catch(Exception ex)
   {
      MessageBox.Show(ex.Message);
   }
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

TwainException Class
TwainException Members

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.