Capturing an Active Window (Builder 3.0)

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

1.

Start Builder 3.0.

2.

In the File menu, choose New Application.

3.

On the Builder 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:

 

void __fastcall TForm1::CapWinClick(TObject *Sender)

{
LEADScr1->CaptureHotKey = VK_F11;
LEADScr1->CaptureDelay = 2000;
LEADScr1->CaptureActiveWindow();
LEAD1->Bitmap = LEADScr1->Bitmap;
}

 

8.

Code the main form's FormClose procedure as follows:

 

void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)

{
LEADScr1->StopCapture();
}

 

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.