Analitcs

Pesquisar no conteúdo do blog.atlabs.com.br

quarta-feira, 18 de setembro de 2013

DELPHI - PrintScreen com 2 monitores (Somente 2º Monitor) - PrintScreen with 2 monitors (Only 2nd Monitor)

Reações: 


procedure TForm1.FormCreate(Sender: TObject);
var
  Captura : TBitMap;
  procedure PrintScreen(Var Image: TBitmap);
  var
    cCanvas: TCanvas;
    I, L :  Integer;
    AreaFinal, AreaOriginal : TRect;
  begin
      try
        For I := 0 to Screen.MonitorCount -1 do
        begin
          if Screen.Monitors[I].Primary then
          begin
            L := Screen.Monitors[i].Width;
          End
          else
          if not Screen.Monitors[I].Primary then
          begin
            cCanvas        := TCanvas.Create;
            cCanvas.Handle := GetWindowDC(GetDesktopWindow);
            try
              AreaOriginal := Rect(Screen.Monitors[i].Left,
                                   Screen.Monitors[i].Top,
                                   Screen.Monitors[i].Left + Screen.Monitors[i].Width,
                                   Screen.Monitors[i].Top + Screen.Monitors[i].Height);
                                 
              AreaFinal    := Rect(0,
                                   0,
                                   Screen.Monitors[i].Width,
                                   Screen.Monitors[i].Height);
              Image.Width  := Screen.Monitors[i].Width;
              Image.Height := Screen.Monitors[i].Height;
              Image.Canvas.CopyRect(AreaFinal, cCanvas, AreaOriginal);
              Break;
            finally
              ReleaseDC(0, cCanvas.Handle);
              cCanvas.Free;
            end;
          end;
        End;
      Finally
      end;
  end;
begin
  try
    Captura := TBitmap.Create;
    PrintScreen(Captura);
    Image1.Picture.Bitmap := Captura;
  finally
    Captura.SaveToFile('c:\teste.bmp');
    FreeAndNil(Captura);
  end;
end;

Nenhum comentário:

Postar um comentário

Observação: somente um membro deste blog pode postar um comentário.

Max Gehringer