LEADTOOLS Multimedia (Leadtools.Multimedia assembly)
LEAD Technologies, Inc

ErrorAbort Event (ConvertCtrl)

Example 





Occurs when an error has caused an operation to abort.
Syntax
public event ErrorAbortEventHandler ErrorAbort
'Declaration
 
Public Event ErrorAbort As ErrorAbortEventHandler
'Usage
 
Dim instance As ConvertCtrl
Dim handler As ErrorAbortEventHandler
 
AddHandler instance.ErrorAbort, handler
public event ErrorAbortEventHandler ErrorAbort
add_ErrorAbort(function(sender, e))
remove_ErrorAbort(function(sender, e))

public:
event ErrorAbortEventHandler^ ErrorAbort
Remarks
The event handler is passed an ErrorAbortEventArgs object containing the related error code.

For more information, refer to the Error Codes.

Example
Copy CodeCopy Code  
Public _result As Boolean = False
      Public _form As ConvertCtrlForm = New ConvertCtrlForm()
      Public Sub ErrorAbortExample()
         ' reference the convert control
         Dim convertctrl As ConvertCtrl = _form.ConvertCtrl

         convertctrl.Window = _form.Handle

         ' input and output file names
         Dim inFile As String = Path.Combine(LEAD_VARS.MediaDir, "ConvertCtrl_ErrorAbortSource.mpeg")
         Dim outFile As String = Path.Combine(LEAD_VARS.MediaDir, "ConvertCtrl_ErrorAbortExample.mpg")

         Try
            ' subscribe to the ErrorAbort event
            AddHandler convertctrl.ErrorAbort, AddressOf ConvertCtrl_ErrorAbort

            ' no recompression for video and audio
            convertctrl.VideoCompressors.Selection = -1
            convertctrl.AudioCompressors.Selection = -1

            ' set the allowed streams and target type
            convertctrl.AllowedStreams = convertctrl.TargetFormats(TargetFormatType.MPEG2DICOM).Streams
            convertctrl.TargetFormat = TargetFormatType.MPEG2DICOM

            ' set the source and target files
            convertctrl.SourceFile = inFile
            convertctrl.TargetFile = outFile

            ' show preview
            convertctrl.Preview = True

            ' convert it now!
            convertctrl.StartConvert()
         Catch e1 As Exception
            _result = False
         End Try

         ' we'll loop on the state and pump messages for this example.
         ' but you should not need to if running from a Windows Forms application.
         Do While convertctrl.State = ConvertState.Running
            Application.DoEvents()
         Loop
      End Sub

      Public Sub ConvertCtrl_ErrorAbort(ByVal sender As Object, ByVal e As ErrorAbortEventArgs)
         ' uncomment this line to show the error message
         ' MessageBox.Show(e.errorMessage, "Convert Error");

         ' set result
         _result = True
      End Sub

Public NotInheritable Class LEAD_VARS
   Public Const MediaDir As String = "C:\Program Files (x86)\LEAD Technologies\LEADTOOLS 175\Media";
End Class
public bool _result = false;
      public ConvertCtrlForm _form = new ConvertCtrlForm();
      public void ErrorAbortExample()
      {
         // reference the convert control
         ConvertCtrl convertctrl = _form.ConvertCtrl;

         convertctrl.Window = _form.Handle;

         // input and output file names
         string inFile = Path.Combine(LEAD_VARS.MediaDir,"ConvertCtrl_ErrorAbortSource.mpeg");
         string outFile = Path.Combine(LEAD_VARS.MediaDir, "ConvertCtrl_ErrorAbortExample.mpg");

         try
         {
            // subscribe to the ErrorAbort event
            convertctrl.ErrorAbort += ConvertCtrl_ErrorAbort;

            // no recompression for video and audio
            convertctrl.VideoCompressors.Selection = -1;
            convertctrl.AudioCompressors.Selection = -1;

            // set the allowed streams and target type
            convertctrl.AllowedStreams = convertctrl.TargetFormats[TargetFormatType.MPEG2DICOM].Streams;
            convertctrl.TargetFormat = TargetFormatType.MPEG2DICOM;

            // set the source and target files
            convertctrl.SourceFile = inFile;
            convertctrl.TargetFile = outFile;

            // show preview
            convertctrl.Preview = true;

            // convert it now!
            convertctrl.StartConvert();
         }
         catch (Exception)
         {
            _result = false;
         }

         // we'll loop on the state and pump messages for this example.
         // but you should not need to if running from a Windows Forms application.
         while (convertctrl.State == ConvertState.Running)
            Application.DoEvents();
      }

      public void ConvertCtrl_ErrorAbort(object sender, ErrorAbortEventArgs e)
      {
         // uncomment this line to show the error message
         // MessageBox.Show(e.errorMessage, "Convert Error");

         // set result
         _result = true;
      }

static class LEAD_VARS
{
   public const string MediaDir = @"C:\Program Files (x86)\LEAD Technologies\LEADTOOLS 175\Media";
}
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

ConvertCtrl Class
ConvertCtrl Members

 

 


Products | Support | Contact Us | Copyright Notices

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

Leadtools.Multimedia requires a Multimedia or Multimedia Suite license and unlock key. For more information, refer to: LEADTOOLS Toolkit Features