Leadtools.Multimedia Namespace > ConvertCtrl Class : ErrorAbort Event |
'Declaration Public Event ErrorAbort As ErrorAbortEventHandler
'Usage Dim instance As ConvertCtrl Dim handler As ErrorAbortEventHandler AddHandler instance.ErrorAbort, handler
public event ErrorAbortEventHandler ErrorAbort
public: event ErrorAbortEventHandler^ ErrorAbort
For more information, refer to the Error Codes.
Imports Leadtools Imports Leadtools.Multimedia Imports LeadtoolsMultimediaExamples.Fixtures 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 18\Media" End Class
using Leadtools; using Leadtools.Multimedia; using LeadtoolsMultimediaExamples.Fixtures; 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 18\Media"; }