Hi, nach kurzer Suche in google hab ich fogendes gefunden. Kannst es ja auf deine Ansprüche kürzen. Dankesschreiben bitte an den Author
This procedure prints many components using printer.canvas. See Tmemo:
procedure TForm1.SpeedButton6Click(Sender: TObject);
Var
i,j, lrand, orand: integer;
r: real;
begin
lrand := 0; {linker Rand in Bildsch.-Punkten}
orand := 0; {oberer Rand }
r := Printer.PageWidth / Form1.Width;
{ p := Printer.PageHeight / Form1.Height; }
Printer.BeginDoc;
for i := 0 to ComponentCount -1 do
begin
If (Components[i] is Tedit)
and (TEdit(Components[i]).Visible = true) then
begin
Printer.Canvas.Font := Tedit(Components[i]).Font;
Printer.Canvas.TextOut(
Trunc(r * (Tedit(Components[i]).Left + lrand)),
Trunc(r * (Tedit(Components[i]).Top + orand)),
Tedit(Components[i]).Text);
end
else If (Components[i] is TDBedit)
and (TDBEdit(Components[i]).Visible = true) then
begin
Printer.Canvas.Font := TDBedit(Components[i]).Font;
Printer.Canvas.TextOut(
Trunc(r * (Tdbedit(Components[i]).Left + lrand)),
Trunc(r * (Tdbedit(Components[i]).Top + orand)),
TDBedit(Components[i]).Text);
end
else If (Components[i] is TComboBox)
and (TComboBox(Components[i]).Visible = true) then
begin
Printer.Canvas.Font := TComboBox(Components[i]).Font;
Printer.Canvas.TextOut(
Trunc(r * (TComboBox(Components[i]).Left + lrand)),
Trunc(r * (TComboBox(Components[i]).Top + orand)),
TComboBox(Components[i]).Text);
end
else If (Components[i] is TDBComboBox)
and (TDBComboBox(Components[i]).Visible = true) then
begin
Printer.Canvas.Font := TDBComboBox(Components[i]).Font;
Printer.Canvas.TextOut(
Trunc(r * (TDBComboBox(Components[i]).Left + lrand)),
Trunc(r * (TDBComboBox(Components[i]).Top + orand)),
TDBComboBox(Components[i]).Text);
end
else If (Components[i] is TLabel)
and (TLabel(Components[i]).Visible = true) then
begin
if Tlabel(components[i]).Alignment = taLeftJustify then
begin
Printer.Canvas.Font := TLabel(Components[i]).Font;
Printer.Canvas.TextOut(
Trunc(r * (TLabel(Components[i]).Left + lrand)),
Trunc(r * (TLabel(Components[i]).Top + orand)),
TLabel(Components[i]).Caption);
end
else
begin
Printer.Canvas.Font := TLabel(Components[i]).Font;
Printer.Canvas.TextOut(
Trunc(r * (TLabel(Components[i]).Left
- TLabel(Components[i]).Width + lrand)
Printer.Canvas.Textwidth(TLabel(Components[i]).Caption)),
Trunc(r * (TLabel(Components[i]).Top + orand)),
TLabel(Components[i]).Caption);
end
end
else If (Components[i] is TImage)
and (TImage(Components[i]).Visible = true) then
begin
Printer.Canvas.Draw(
Trunc(r * (TImage(Components[i]).Left + lrand)),
Trunc(r * (TImage(Components[i]).Top + orand)),
TImage(Components[i]).Picture.Bitmap);
end
else If (Components[i] is TDBImage)
and (TDBImage(Components[i]).Visible = true) then
begin
Printer.Canvas.Draw(
Trunc(r * (TDBImage(Components[i]).Left + lrand)),
Trunc(r * (TDBImage(Components[i]).Top + orand)),
TDBImage(Components[i]).Picture.Bitmap);
end
else If (Components[i] is TShape)
and (TShape(Components[i]).Visible = true) then
begin
Printer.Canvas.Rectangle(
Trunc(r * (TShape(Components[i]).Left + lrand)),
Trunc(r * (TShape(Components[i]).Top + orand)),
Trunc(r * (TShape(Components[i]).Left +
TShape(Components[i]).Width + lrand)),
Trunc(r * (TShape(Components[i]).Top +
TShape(Components[i]).Height + orand)));
end
else If (Components[i] is TMemo)
and (TMemo(Components[i]).Visible = true) then
begin
Printer.Canvas.Font := TMemo(Components[i]).Font;
for j := 0 to TMemo(Components[i]).Lines.count do
Printer.Canvas.TextOut(
Trunc(r * (TMemo(Components[i]).Left + lrand)),
Trunc(r * (TMemo(Components[i]).Top
- TMemo(Components[i]).Font.Height * j * 1.2 + orand)),
TMemo(Components[i]).Lines[j]);
end
{XXXXXXXXXXXXX DBMemo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
else If (Components[i] is TDBMemo)
and (TDBMemo(Components[i]).Visible = true) then
begin
Printer.Canvas.Font := TDBMemo(Components[i]).Font;
for j := 0 to TDBMemo(Components[i]).Lines.count do
Printer.Canvas.TextOut(
Trunc(r * (TDBMemo(Components[i]).Left + lrand)),
Trunc(r * (TDBMemo(Components[i]).Top
- TDBMemo(Components[i]).Font.Height * j * 1.2 +
orand)),
TDBMemo(Components[i]).Lines[j]);
end;
end;
Printer.EndDoc;
Memo2.Visible := true;
ComboBox1.Visible := true;
end;
–
Klaus Gotthardt
email: [email protected]
home : http://www.rz.uni-frankfurt.de/~gotthard