Einzelnen Beitrag anzeigen

Skrenkovic

Registriert seit: 7. Jan 2014
9 Beiträge
 
FreePascal / Lazarus
 
#1

Screenshot aber wie?!

  Alt 8. Jan 2014, 16:52
Hi Ihr Programmier lustigen

Ich habe in einem anderem Forum (bitte Verzeiht mir) einen Code gefunden der genau passt bis auf zwei Kleinigkeiten.
1) Wie kann ich den Code so umschreiben dass der mir auf "Form4" den Screenshot macht und
2) Wo ist der Fehler (in der Zeile wo die ganzen ################### sind ^^
Es kommt folgende Fehlermeldung: unit3.pas(76,40) Fatal: Syntax error, ")" expected but "," found


Code:
procedure TForm1.Button5Click(Sender: TObject);
 
var
  MyBitmap: TBitmap;
  MyBitmap2: TBitmap;
  MyDC: HDC;
  png: TPortableNetworkGraphic;
  R: TRect;
begin
  R.TopLeft := Form1.BoundsRect.TopLeft;
  R.BottomRight := Form1.BoundsRect.BottomRight;
  MyDC := GetDC(Self.Handle);
  MyBitmap := TBitmap.Create;
  MyBitmap2 := TBitmap.Create;
  MyBitmap2.Width := R.Right - R.Left;
  MyBitmap2.Height := R.Bottom - R.Top;
  png := TPortableNetworkGraphic.Create;
 
  try
    MyBitmap.LoadFromDevice(MyDC);
    MyBitmap.SaveToFile('FormsAppearance.bmp');
    //MyBitmap2.Canvas.CopyRect(ClientRect,MyBitmap.Canvas,ClientRect);
    ########################################MyBitmap2.Canvas.copyRect(Rect(0, 0, MyBitmap2.Width, MyBitmap2.Height),MyBitmap.Canvas, R);
    MyBitmap2.SaveToFile('FormsAppearance2.bmp');
    png.Assign(MyBitmap2);
    png.SaveToFile('shottest.png');
  finally
    ReleaseDC(Self.Handle, MyDC);
    FreeAndNil(MyBitmap);
    FreeAndNil(MyBitmap2);
    png.Free;
  end;
end;
die screenshots werden erstellt ... aber das png ist schwarz ...
  Mit Zitat antworten Zitat