Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Panel drucken inkl. Kompos (https://www.delphipraxis.net/93647-panel-drucken-inkl-kompos.html)

capo 8. Jun 2007 22:01


Panel drucken inkl. Kompos
 
Hallo
Wie kann ich ein Panel drucken inkl. den darauf sitzenden Kompos?
Geht sowas überhaupt?
gruss vomm capo

bitsetter 9. Jun 2007 00:04

Re: Panel drucken inkl. Kompos
 
Moin moin,

kannst ja mal testen ob das was bringt:
Delphi-Quellcode:
uses Printers;

Procedure BildAusSchnitt(hWND: HWND; iLeft, iTop, iWidth, iHeight: integer);
var
  c: TCanvas;
begin
  BringWindowToTop(hWND);
  c:= TCanvas.Create;
  c.Handle:= GetWindowDC(hWND);
  try
    printer.begindoc;
    printer.Canvas.CopyRect(Rect(0, 0, iWidth* 10, iHeight* 10), c, Rect(iLeft, iTop, iLeft+ iWidth, iTop+ iHeight));
    printer.enddoc;
  finally
    ReleaseDC(hWND, c.handle);
    c.Free;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
   BildAusSchnitt(Panel1.Handle, 0, 0, Panel1.Width, Panel1.Height);
end;

capo 9. Jun 2007 10:21

Re: Panel drucken inkl. Kompos
 
Das klappt nicht nur suupergut, sieht auch noch echt Klasse aus.
Danke
capo

capo 11. Jun 2007 06:33

Re: Panel drucken inkl. Kompos
 
Noch eine Frage dazu, kann man auch die Position des Panels beim ausdrucken bestimmen?
Ich hab das so versucht:
Delphi-Quellcode:
printer.Canvas.CopyRect(Rect(200, 200, iWidth* 10, iHeight* 10), c, Rect(iLeft, iTop, iLeft+ iWidth,
Merkwürdigerweise wird das Panel beim ausdrucken ab einem bestimmten Wert gestaucht/verzerrt dargestellt.
Capo

bitsetter 11. Jun 2007 08:33

Re: Panel drucken inkl. Kompos
 
Hallo,

dazu muss man das Ganze wohl etwas umbauen:
Delphi-Quellcode:
Procedure PrintWinControl(hWND: HWND; iLeft, iTop, iWidth, iHeight: integer);
var
  c: TCanvas;
begin
  iLeft := iLeft * 10;
  iTop := iTop * 10;
  BringWindowToTop(hWND);
  c:= TCanvas.Create;
  c.Handle:= GetWindowDC(hWND);
  try
    printer.begindoc;
    //Windows.SetMapMode(printer.Canvas.Handle, MM_LOMETRIC);
    printer.Canvas.CopyRect(Rect(iLeft, iTop, iLeft + iWidth * 10, iTop + iHeight * 10), c, Rect(0, 0, iWidth, iHeight));
    printer.enddoc;
  finally
    ReleaseDC(hWND, c.handle);
    c.Free;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
   PrintWinControl(Panel1.Handle, 80, 140, Panel1.Width, Panel1.Height);
end;

capo 11. Jun 2007 11:42

Re: Panel drucken inkl. Kompos
 
Danke....habs sogar verstanden :)


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:22 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz