This short article will explain you how to capture screen content to a JPEG file from the Delphi program.
First create a new project. (I assume you already have experience with Delphi programming so I will not go into detail on how to create a Delphi project.) Save it, for example, as ScrnCap. Rename main form as frmCapture. Add a TButton control and a TSaveDialog. Rename button control as btnStartCapture and change its Caption properties to 'Capture'. Rename save dialog as dlgSaveCapture.
Create a new unit and rename is as uscreencap.pas. Add the following code:
procedure CaptureScreenShot(acapture: TBitMap);
var c: TCanvas;
c.Handle:= GetWindowDC (GetDesktopWindow);
acapture.Canvas.CopyRect(r, c, r);
Do not forget to add jpeg.pas unit in uses clause of unit interface part. This is where TJPEGImage class is declared. Save it when you are finished.
Now in your main application unit where the main form resides, add button OnClick event handler. Fill the code in exactly as it is below:
if dlgSaveCapture.Execute the
Do not forget to include uscreencap.pas and jpeg.pas unit in your uses clause. Build project and run. Every time you clickcapture button, your screen is saved to JPEG file.