1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
procedure ScreenShotWindow;
var
c: TCanvas;
r, t: TRect;
h: THandle;
Bild: TBitMap;
large,haut:integer;
begin
c := TCanvas.Create;
{h := FindWindow(nil, 'Microsoft Edge'); }
h := FindWindow(nil, 'Sans titre - Paint');
c.Handle := GetWindowDC(h);
GetWindowRect(h, t);
large:=(t.Right-t.Left)-20;
haut:=(t.Bottom-t.Top)-150;
t.Left:=t.Left+10;
t.Top:=t.Top+150;
try
r := Rect(0, 0,large ,haut );
Bild := TBitMap.Create;
try
Bild.Width := large;
Bild.Height := haut;
Bild.Canvas.CopyRect(r, c, t);
Bild.SaveToFile('test.bmp');
finally
Bild.Free;
end;
finally
ReleaseDC(0, c.Handle);
c.Free;
form1.Image1.Picture.LoadFromFile('test.bmp');
end;
end; |
Partager