procedure TForm5.Button3Click(Sender: TObject);
begin
with ADOQuery1 do
begin
with SQL do
begin
Clear;
Add('SELECT *');
Add('FROM Coordinates'); end;
Open;
first;
while NOT EOF do
begin
w:= FieldByName('1').Asinteger;
x:= FieldByName('2').Asinteger;
y:= FieldByName('3').Asinteger;
z:= FieldByName('4').Asinteger;
done := done+1;
GetImage(w,x,y,z); next;
end;
percentatge := 0;
end;
end;
procedure Tform5.GetImage(w,x,y,z :integer);
const
FullWindow = True;
var
Win: HWND;
DC: HDC;
Bmp: TBitmap;
FileName: string;
WinRect: TRect;
Width: Integer;
Height: Integer;
Handle: THandle;
Len: LongInt;
Title: string;
id : integer;
c: TCanvas;
WinMessage : tmessage;
rect_source, rect_destination : TRect;
file : integer;
begin
file:=file+1;
c := TCanvas.Create;
try
if length(WinName) <> 0 then begin
Win := DestinWindow(WinName); end else
begin
Form5.Hide; Win := GetActiveWindow;
WinName:= activecaption;
end;
Application.ProcessMessages; if FullWindow then
begin
GetWindowRect(Win, WinRect);
c.Handle := GetWindowDC(Win);
end else
begin
Windows.GetClientRect(Win, WinRect);
DC := GetDC(Win);
end;
if iswindowvisible(WIN) = true then begin;
ShowWindow(WIN,SW_RESTORE);
end
Bmp := TBitmap.Create;
winrect.Right := winrect.Right;
rect_source := Rect(W,X,Y,Z);
Bmp.Width := 23;
Bmp.Height := 14;
try
BitBlt(Bmp.Canvas.Handle, 0, 0, Width, Height, DC, 0, 0, SRCCOPY);
Bmp.Canvas.CopyRect(rect_destination, c, rect_source);
FileName := 'Screenshot_' + inttostr(arxiu);
while fileexists(Format('C:\Screenshots\%s.bmp', [FileName])) do
begin
file:=file+1;
FileName := 'Screenshot_' + inttostr(file);
end;
Bmp.SaveToFile(Format('C:\Screenshots\%s.bmp', [FileName]));
finally
Bmp.Free;
end;
finally
ReleaseDC(Win, DC);
end;
Form5.Show;
end;