Einzelnen Beitrag anzeigen

Benutzerbild von Jonas Shinaniganz
Jonas Shinaniganz

Registriert seit: 30. Aug 2011
249 Beiträge
 
Delphi XE5 Ultimate
 
#10

AW: Verantwortlichkeiten / Wer kümmert sich um Freigeben

  Alt 26. Jul 2012, 13:30
Lemmy zur sicherheit poste Ich nochmal was Ich implementiert habe, vielleicht hab Ichs ja noch nicht ganz richtig gemacht:

Die API der TReportUnit bietet:

Delphi-Quellcode:
  
  procedure AddBlock(Text : String; Image : TBitmap);
  procedure Generate;
Der AddBlock macht jetzt folgendes:

Delphi-Quellcode:
procedure TReportUnit.AddBlock(Text: String; Image: TBitmap);
var
  Block : TBlock;
begin
  // block erstellen
  Block := TBlock.Create;
  // bild und text KOPIEREN
  Block.FImage.Assign(Image);
  Block.FText := Text;
  // block in Blockliste übernehmen
  FBlocks.Add(Block);
end;
Block.FImage.Assign(Image); ist wohl die wichtige Zeile hierbei.


Und mit FBlocks.OwnsObjects := True; habe Ich eine kompfort Freigabemöglichkeit

und mein code im Aufruft sieht jetzt so aus:

Delphi-Quellcode:
function TTestActionMCOReport.Execute: TActionResult;
var
  ReportUnit : TReportUnit;
  Bitmap1 : TBitmap;
begin
  ReportUnit := TReportUnit.Create;
  ReportUnit.TemplateFile := TTestActionMCOReportParam(Parameter).TemplateFileName;
  ReportUnit.PDFDokumentOutputPath := TTestActionMCOReportParam(Parameter).PDFDokumentOutputPath;

  // Hier müssen die Bilder welche dann auch im Report sein sollen mit AddBlock hinzugefügt werden
  Bitmap1 := TBitmap.Create;
  Bitmap1.LoadFromFile...
// Oder Vielleicht kopiere Ich das Bitmap auch aus einem Stream oder DB oder wie auch immer
  ReportUnit.AddBlock('Hysterese Test 1', Bitmap1);
  Bitmap1.Free; // Erstes Freigeben weil Bild ja jetzt in Reportunit Existent ist

  ReportUnit.Generate;
  ReportUnit.Free;
end;
Die Leiter der Entwicklungsabteilung dreht total am Mausrad!
  Mit Zitat antworten Zitat