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 37 38 39 40 41
|
procedure TForm1.Button6Click(Sender: TObject);
var
h:thandle;
c:tcanvas;
r1, r2,r3: TRect;
large,haut:integer;
b:tbitmap;
begin
// fenêtre de ton message
h := FindWindow('Chrome_WidgetWin_1',nil);
{h:=197374; }
if h = 0 then
Exit;
// canvas du Bureau
c := TCanvas.Create;
c.Handle := GetDC(0);
GetWindowRect(h, r1);
// dimensions de la partie cliente
Windows.GetClientRect(h, r2);
// ajouter en dimensions écran
Windows.ClientToScreen(h, r2.TopLeft);
Windows.ClientToScreen(h, r2.BottomRight);
// bitmap destination
large :=r2.Right-r2.Left;
haut :=r2.Bottom-r2.Top;
r3:=rect(0, 0,large,haut);
b := TBitmap.Create;
b.Width:=large;
b.Height:=haut;
// copier le bureau dans le bitmap
b.Canvas.CopyRect(r3, c, r2);
// le mettre dans une image
Image1.Picture.Bitmap := b;
// faire le ménage
b.Free;
ReleaseDC(0, c.Handle);
c.Handle := 0;
c.Free;
end; |
Partager