Capturing Multiple Images (Delphi 4.0)
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 (Delphi). |
|
2. |
Add two command buttons and name them as follows: |
|
|
Name |
Caption |
|
CapMulti |
Capture Multi |
|
Display |
Display Multi |
3. |
Code the CapMultiClick procedure as follows: |
procedure TForm1.CapMultiClick(Sender: TObject);
begin
{set the cancel key}
LEADScr1.CaptureCancelKey := VK_ESCAPE;
{set the delay, the interval, and the number of captures to perform}
LEADScr1.CaptureDelay := 2000;
LEADScr1.CaptureInterval := 2000;
LEADScr1.CaptureCount := 3;
{capture}
LEADScr1.CaptureActiveClient();
end;
4. |
Code the DisplayClick procedure as follows: |
procedure TForm1.DisplayClick(Sender: TObject);
begin
LEAD1. Load('D:\Temp\Multi.tif', 0, 1, 1);
LEAD2.Load('D:\Temp\Multi.tif', 0, 2, 1);
LEAD3.Load('D:\Temp\Multi.tif', 0, 3, 1);
{remove the tif file so you can capture and display again without having to restart the program}
DeleteFile('D:\Temp\Multi.tif');
end;
5. |
Code the OnCaptureImage procedure as follows: |
procedure TForm1.LEADScr1CaptureImage(Sender: TObject;
nCurrentPageNumber: Integer);
begin
{copy the captured image to the Main control and save it}
LEAD1.Bitmap:= LEADScr1.Bitmap;
LEAD1. Save('D:\Temp\Multi.tif', FILE_TIF, 0, 2, SAVE_APPEND);
end;
6. |
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. |