Einzelnen Beitrag anzeigen

zeras

Registriert seit: 11. Mär 2007
Ort: Saalkreis
1.618 Beiträge
 
Delphi 12 Athens
 
#2

AW: ScreenShot eines Fensters machen dessen Inhalt größer Formgröße ist

  Alt 16. Mär 2013, 15:06
Ich meine, dass ich vor einiger Zeit das gleiche Problem hatte. Versuche es doch mal mit diesem Code.
Delphi-Quellcode:


  procedure ScreenShot(wnd: HWND; destBitmap : TBitmap) ;
  var
    w,h : integer;
    DC : HDC;
    r : TRect;
    DCProgr : HDC;

  begin
    SetActiveWindow(wnd);

    DCProgr:=GetForegroundWindow;

    if DCProgr <> wnd then begin
      SetForegroundWindow(wnd);
      sleep(Delay4ScreenShot);
    end;

    dc := GetWindowDC(wnd) ;
    GetWindowRect(wnd,r) ;
    w := r.Right - r.Left;
    h := r.Bottom - r.Top;
    try
      destBitmap.Width := w;
      destBitmap.Height := h;
      BitBlt(destBitmap.Canvas.Handle,
               0,
               0,
               destBitmap.Width,
               destBitmap.Height,
               DC,
               0,
               0,
               SRCCOPY) ;
    finally
      ReleaseDC(wnd, DC) ;
    end;

    SetForegroundWindow(DCProgr);
  end;
Matthias
Es ist nie falsch das Richtige zu tun!
- Mark Twain
  Mit Zitat antworten Zitat