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: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86:
| <span style="font-weight: bold">procedure ScreenCapture(Bmp: TBitmap; Form: TForm);</span> var DeskWnd: HWnd; DeskDC: HDC; DeskCv: TCanvas; R: TRect; W, H: Integer; begin if Bmp = nil then Exit; DeskWnd:= Form.handle; DeskDC := GetWindowDC(DeskWnd); DeskCv := TCanvas.Create; DeskCv.Handle := DeskDC;
If (Form<>nil) then Begin W := Form.Width; H := Form.Height; end else Begin W := Screen.Width; H := Screen.Height; end;
R := Bounds(0, 0, W, H); try Bmp.HandleType := bmDIB; Bmp.PixelFormat := pfDevice; Bmp.Width := W ; Bmp.Height:= H ; Bmp.Canvas.CopyMode := cmSrcCopy; Bmp.Canvas.CopyRect(R, DeskCv, R); finally DeskCv.Free; ReleaseDC(DeskWnd, DeskDC); end; end;
<span style="font-weight: bold"> Procedure PrintScreenshot(Form: TForm; BlattAusrichtung:TPrinterOrientation);</span> var Bmp: TBitmap; sizex,sizey : Integer; begin Bmp:= TBitmap.Create; ScreenCapture(bmp,Form); Printer.Orientation:=BlattAusrichtung; Printer.BeginDoc; Setuppage(sizex,sizey); Printer.Canvas.StretchDraw(Rect(0,0,sizex,sizey),bmp); Printer.EndDoc; Bmp.Free; end;
procedure TForm1.Edit1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); var Bitmap: TBitmap; sizex,sizey:Integer; begin
Bitmap := TBitmap.Create; If ((ssAlt in Shift) AND (Key= VK_SnapShot)) then begin Bitmap.Assign(Clipboard); Bitmap.Width:=form1.Width; Bitmap.Height:=form1.height; end;
If (Key=VK_SnapShot) then Begin Bitmap.Assign(Clipboard); Bitmap.Width:=screen.Width; Bitmap.Height:=screen.height; end; <span style="font-weight: bold"> Image1.Width:=Bitmap.Width; Image1.Height:=Bitmap.Height; Image1.Picture.Assign(Bitmap) ; </span>
Printer.Orientation:=poLandscape; Printer.BeginDoc; <span style="font-weight: bold"> Printer.Canvas.Draw(500,500,TGraphic(Bitmap));</span> Printer.EndDoc;
Bitmap.free; end;<span style="font-weight: bold"></span> |