Capturing an Active Window (Delphi 4.0)

Take the following steps to start a project and to add some code that captures the active window.

1.

Start Delphi 4.0.

2.

In the File menu, choose New Application.

3.

On the Delphi toolbar, click the VCL tab. If you have used a LEAD VCL control before, the icon appears on the toolbar. Otherwise, refer to Installing VCL before continuing with this tutorial.

4.

Select the LEAD Main Control on the VCL toolbar and add it to the form. Size and position the control as you want it to appear at run time. Change the Name to LEAD1.

5.

Select the LEAD Screen Capture Control on the VCL toolbar and add it to the form. Change the Name to LEADScr1.

6.

Add a command button and name it as follows:

 

Name

Caption

 

CapWin

Capture Window

7.

Code the CapWinClick procedure as follows:

 

procedure TForm1.CapWinClick(Sender: TObject);
begin
LeadScr1.CaptureHotKey := VK_F11;
LeadScr1.CaptureDelay := 2000;
LeadScr1.CaptureActiveWindow();
Lead1.Bitmap:= LeadScr1.Bitmap;
end;

 

8.

Code the main form's FormClose procedure as follows:

 

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
LeadScr1.StopCapture();
end;

 

9.

Run your program to test it. Click the Capture Window command button, select the window to capture, and press F11.

10.

Save the project to use as a starting point for other tasks in the tutorial.