Leadtools.ScreenCapture Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.8.31
ScreenCaptureException Class
See Also  Members   Example 
Leadtools.ScreenCapture Namespace : ScreenCaptureException Class




The exception that is thrown when a LEADTOOLS ScreenCapture error occurs.

Syntax

Visual Basic (Declaration) 
<SerializableAttribute()>
Public Class ScreenCaptureException 
   Inherits LeadtoolsException
Visual Basic (Usage)Copy Code
Dim instance As ScreenCaptureException
C# 
[SerializableAttribute()]
public class ScreenCaptureException : LeadtoolsException 
Managed Extensions for C++ 
[SerializableAttribute()]
public __gc class ScreenCaptureException : public LeadtoolsException 
C++/CLI 
[SerializableAttribute()]
public ref class ScreenCaptureException : public LeadtoolsException 

Example

Visual BasicCopy Code
Public Sub scEngine_CaptureInformation(ByVal sender As Object, ByVal e As ScreenCaptureInformationEventArgs) Handles scEngine.CaptureInformation
   ' Define codecs class object to save the image
   RasterCodecs.Startup()
   Dim codecs As New RasterCodecs()
   codecs.ThrowExceptionsOnInvalidImages = True

   ' Save the resulted Image
   codecs.Save(e.Image, "C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\CapturedImage.bmp", RasterImageFormat.Bmp, 24)

   RasterCodecs.Shutdown()

   ' NOTE: e.Information is a ScreenCaptureInformation structure filled with information
   ' about the captured image, this information can be used here
   ' Display a MessageBox with the bounds of the capture area
   MessageBox.Show("Captured Area Bounds:" & Environment.NewLine & "Top:" & e.Information.Area.Top.ToString() & Environment.NewLine & "Left:" & e.Information.Area.Left.ToString() & Environment.NewLine & "Right:" + e.Information.Area.Right.ToString() & Environment.NewLine & "Bottom:" & e.Information.Area.Bottom.ToString())

   ' everything worked fine
   e.Cancel = False
End Sub

WithEvents scEngine As ScreenCaptureEngine

Public Sub ScreenCaptureExceptionExample()
   ScreenCaptureEngine.Startup()
   Dim captureInformation As ScreenCaptureInformation = Nothing
   scEngine = New ScreenCaptureEngine()

   Try
      MessageBox.Show("After you close this message box," & Environment.NewLine & "press F11 to capture the wallpaper.")
      Dim image As RasterImage = scEngine.CaptureWallpaper(captureInformation)
   Catch ex As ScreenCaptureException
      ' LEADTOOLS ScreenCapture Error
      MessageBox.Show(String.Format("Could not capture wallpaper.{0}ScreenCapture error code: {1}{0}Message: {2}", Environment.NewLine, ex.Code, ex.Message))
   Catch ex As Exception
      ' Other errors
      MessageBox.Show(String.Format("Could not capture wallpaper.{0}{1}", Environment.NewLine, ex.Message))
   End Try
   ScreenCaptureEngine.Shutdown()
End Sub
C#Copy Code
void scEngine_CaptureInformation(object sender, ScreenCaptureInformationEventArgs e) 

   // Make sure that the image was captured successfully 
   Debug.Assert(e.Image != null); 
   // Define codecs class object to save the image 
   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   // Save the resulted Image 
   codecs.Save(e.Image, @"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\CapturedImage.bmp", RasterImageFormat.Bmp, 24); 
 
   RasterCodecs.Shutdown(); 
 
   // NOTE: e.Information is a ScreenCaptureInformation structure filled with information 
   // about the captured image, this information can be used here 
   // Display a MessageBox with the bounds of the capture area 
   MessageBox.Show("Captured Area Bounds:\n" + 
      "Top:" + e.Information.Area.Top.ToString() + "\n" + 
      "Left:" + e.Information.Area.Left.ToString() + "\n" + 
      "Right:" + e.Information.Area.Right.ToString() + "\n" + 
      "Bottom:" + e.Information.Area.Bottom.ToString()); 
 
   // everything worked fine 
   e.Cancel = false; 

 
 
public void ScreenCaptureExceptionExample() 

   ScreenCaptureEngine.Startup(); 
   ScreenCaptureEngine scEngine = new ScreenCaptureEngine(); 
   ScreenCaptureInformation captureInformation = null; 
   scEngine.CaptureInformation += new EventHandler<ScreenCaptureInformationEventArgs>(scEngine_CaptureInformation); 
 
   try 
   { 
      MessageBox.Show("After you close this message box,\npress F11 to capture the wallpaper."); 
      RasterImage image = scEngine.CaptureWallpaper(captureInformation); 
   } 
   catch (ScreenCaptureException ex) 
   { 
      //LEADTOOLS ScreenCapture Error 
      MessageBox.Show(string.Format("Could not capture wallpaper.{0}ScreenCapture error code: {1}{0}Message: {2}", Environment.NewLine, ex.Code, ex.Message)); 
   } 
   catch (Exception ex) 
   { 
      // Other errors 
      MessageBox.Show(string.Format("Could not capture wallpaper.{0}{1}", Environment.NewLine, ex.Message)); 
   } 
   ScreenCaptureEngine.Shutdown(); 
}

Inheritance Hierarchy

System.Object
   System.Exception
      Leadtools.LeadtoolsException
         Leadtools.ScreenCapture.ScreenCaptureException

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also