Capturing Multiple Images (Visual Basic 5 and later)

Take the following steps to add code that will let you capture multiple images.

1.

Start with the project that you created in Capturing an Icon from an EXE.

2.

Add two command buttons and name them as follows:

 

Name

Caption

 

CapMulti

Capture Multi

 

Display

Display Multi

3.

Add the LEAD Raster IO Object Library to your project.

 

On the Project pull-down menu, use the References option, and select the LEAD Raster IO Object Library (14.5).

4.

Code the CapMulti_Click procedure as follows:

Private Sub CapMulti_Click()
   'set the cancel key
   LEADRasterScr1.CaptureCancelKey = vbKeyEscape
   'set the delay, the interval and the number of captures to perform
   LEADRasterScr1.CaptureDelay = 2000
   LEADRasterScr1.CaptureInterval = 2000
   LEADRasterScr1.CaptureCount = 3
   'capture
   LEADRasterScr1.CaptureActiveClient
End Sub

5.

Code the Display_Click procedure as follows:

Private Sub Display_Click()
   Dim LEADRasterIO1 As New LEADRasterIO
   LEADRasterIO1. Load LEADRasterView1.Raster, "D:\Temp\Multi.tif", 0, 1, 1
   MsgBox "Loaded Page 1"
   LEADRasterIO1. Load LEADRasterView1.Raster, "D:\Temp\Multi.tif", 0, 2, 1
   MsgBox "Loaded Page 2"
   LEADRasterIO1. Load LEADRasterView1.Raster, "D:\Temp\Multi.tif", 0, 3, 1
   MsgBox "Loaded Page 3"
   'remove the tif file so you can capture and display again
   Kill "D:\Temp\Multi.tif"
End Sub

6.

Code the OnCaptureImage procedure as follows:

Private Sub LEADRasterScr1_OnCaptureImage (ByVal CaptureNumber As Long)
'copy the captured image to the Main control and save it
   LEADRasterView1.Raster.Bitmap = LEADRasterScr1.Bitmap
   Dim LEADRasterIO1 As New LEADRasterIO
   LEADRasterIO1. Save LEADRasterView1.Raster, "D:\Temp\Multi.tif", FILE_TIF, 0, 2, SAVE_APPEND
End Sub

7.

Run your program to test it. Click on Capture Multi, press F11, and then select the window(s) you wish to capture, at the proper times. You may want to decrease the capture interval in the code. To view the images you captured, click on the Display command button after capturing has ended.