Einzelnen Beitrag anzeigen

Delphi.Narium

Registriert seit: 27. Nov 2017
2.433 Beiträge
 
Delphi 7 Professional
 
#3

AW: Bild vom TWebbrowser erstellen

  Alt 8. Apr 2019, 09:30
Delphi-Quellcode:
{ Bildschirmfotos machen }
function CaptureScreenRect( ARect: TRect ): TBitmap;
var
  ScreenDC: HDC;
begin
  Result := TBitmap.Create;
  with Result, ARect do begin
    Width := Right - Left;
    Height := Bottom - Top;
    ScreenDC := GetDC( 0 );
    try
      BitBlt( Canvas.Handle, 0, 0, Width, Height, ScreenDC, Left, Top, SRCCOPY );
    finally
      ReleaseDC( 0, ScreenDC );
    end;
  end;
end;

{ Bildschirmfotos machen }
function CaptureScreen: TBitmap;
begin
  with Screen do Result := CaptureScreenRect(Rect( 0, 0, Width, Height));
end;

{ Bildschirmfoto eines Controls machen. }
function CaptureClientImage( Control: TControl ): TBitmap;
begin
  with Control, Control.ClientOrigin do
    Result := CaptureScreenRect( Bounds( X, Y, ClientWidth,
                ClientHeight ));
end;

{ Bildschirmfoto eines Controls machen. }
function CaptureControlImage( Control: TControl ): TBitmap;
begin
  with Control do
   if Parent = nil then
      Result := CaptureScreenRect( Bounds( Left, Top, Width, Height ))
    else
      with Parent.ClientToScreen( Point( Left, Top )) do
        Result := CaptureScreenRect( Bounds( X, Y, Width,
                    Height ));
end;

{ Bildschirmfoto eines Controls machen. }
function CaptureWindowImage(Wnd: HWND): TBitmap;
var
  R: TRect;
begin
  GetWindowRect(Wnd, R);
  Result := CaptureScreenRect(R);
end;
Keine Ahnung, wo ich das wann auch immer gefunden habe.

Geändert von Delphi.Narium ( 8. Apr 2019 um 12:49 Uhr) Grund: Schreibfehler - wie immer
  Mit Zitat antworten Zitat