←Select platform

ScreenCaptureException Constructor(string,Exception)

Summary
Initializes a new instance of the ScreenCaptureException class with the specified error message, its Code set to ScreenCaptureExceptionCode.Success and a reference to the inner exception that is the cause of this exception.

Syntax
C#
C++/CLI
Python
public ScreenCaptureException( 
   string message, 
   Exception inner 
) 
public: 
ScreenCaptureException(  
   String^ message, 
   Exception^ inner 
) 
__init__(self,message,inner) # Overloaded constructor 

Parameters

message
The error message that explains the reason for the exception.

inner
The exception that is the cause of the current exception. If the innerException parameter is not a null reference (Nothing in VB), the current exception is raised in a catch block that handles the inner exception.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ScreenCapture; 
 
 
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 codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   // Save the resulted Image 
   codecs.Save(e.Image, Path.Combine(LEAD_VARS.ImagesDir, "Out_CapturedImage.bmp"), RasterImageFormat.Bmp, 24); 
 
 
   // 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(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.ScreenCapture Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.