unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ppPrnabl, ppClass, ppCtrls, ppBands, ppCache, ppEndUsr, ppComm,
ppRelatv, ppProd, ppReport, Buttons, ppDB, ppDBPipe,
DB,
ZAbstractRODataset, ZAbstractDataset, ZDataset, ZConnection, Grids,
DBGrids;
type
TForm1 =
class(TForm)
ppReport1: TppReport;
ppDesigner1: TppDesigner;
ppHeaderBand1: TppHeaderBand;
ppDetailBand1: TppDetailBand;
ppFooterBand1: TppFooterBand;
ppLabel1: TppLabel;
SpeedButton1: TSpeedButton;
ppLabel3: TppLabel;
ppDBPipeline1: TppDBPipeline;
ZConnection1: TZConnection;
ZQuery1: TZQuery;
DataSource1: TDataSource;
ppGroup1: TppGroup;
ppGroupHeaderBand1: TppGroupHeaderBand;
ppGroupFooterBand1: TppGroupFooterBand;
DBGrid1: TDBGrid;
ppLabel2: TppLabel;
ppDBText1: TppDBText;
ppLine1: TppLine;
procedure my_BeforePrint(Sender: TObject);
procedure my_AfterPrint(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
// OK..
{
ErklärBär:
ich suche alle componenten von einem speziellem Band, die ppLabels sind und eine bestimmte Caption haben
Beforeprint: Ich such einen "Fixen" Caption-wert und setz ihn neu
Afterprint: ich such die neue Caption und setz sie wieder zrück..
Das Spiel beginnt von vorne
}
// Für allgemeine Sachen wie Schriftart und so..
procedure AssignFontToReport(aFont: TFont; aReport: TppCustomReport);
var
liBand: Integer;
liObject: Integer;
lObject: TppComponent;
begin
for liBand := 0
to aReport.BandCount-1
do
for liObject := 0
to aReport.Bands[liBand].ObjectCount-1
do
begin
lObject := aReport.Bands[liBand].Objects[liObject];
if lObject.HasFont
then
lObject.Font := aFont;
end;
end;
procedure TForm1.my_BeforePrint(Sender: TObject);
var x:integer;
schleife_baender : Integer;
schleife_Objekte : Integer;
eine_Componente : TppComponent;
text:
String;
begin
for schleife_baender := 0
to ppReport1.BandCount-1
do
begin
if ppReport1.Bands[schleife_baender].ClassName = '
TppDetailBand'
then
begin
for schleife_Objekte := 0
to ppReport1.Bands[schleife_baender].ObjectCount-1
do
begin
eine_Componente := ppReport1.Bands[schleife_baender].Objects[schleife_Objekte];
if eine_Componente.ClassName = '
TppLabel'
then
begin
text:= ZQuery1.FieldByName('
OBJECT_NAME').AsString+#160;
if (eine_Componente
as TppLabel).Caption = '
Wert1'
then (eine_Componente
as TppLabel).Caption :=text;
end;
end;
end;
end;
end;
procedure TForm1.my_AfterPrint(Sender: TObject);
var x:integer;
schleife_baender : Integer;
schleife_Objekte : Integer;
eine_Componente : TppComponent;
text:
String;
begin
for schleife_baender := 0
to ppReport1.BandCount-1
do
begin
if ppReport1.Bands[schleife_baender].ClassName = '
TppDetailBand'
then
begin
for schleife_Objekte := 0
to ppReport1.Bands[schleife_baender].ObjectCount-1
do
begin
eine_Componente := ppReport1.Bands[schleife_baender].Objects[schleife_Objekte];
if eine_Componente.ClassName = '
TppLabel'
then
begin
text:= ZQuery1.FieldByName('
OBJECT_NAME').AsString+#160;
if (eine_Componente
as TppLabel).Caption = text
then (eine_Componente
as TppLabel).Caption := '
Wert1' ;
end;
end;
end;
end;
end;
// heir setz ich die Events neu
procedure TForm1.SpeedButton1Click(Sender: TObject);
var
schleife_baender : Integer;
schleife_Objekte : Integer;
begin
for schleife_baender := 0
to ppReport1.BandCount-1
do
begin
if ppReport1.Bands[schleife_baender].ClassName = '
TppDetailBand'
then
begin
ppReport1.Bands[schleife_baender].BeforePrint:= my_BeforePrint;
ppReport1.Bands[schleife_baender].AfterPrint := my_AfterPrint;
end;
end;
ppreport1.Print;
end;
end.