Question
“How do I change the color of objects inside the report from the preview window?”
Solution
Create a preview plugin that adds a new button to the toolbar. Once this button is clicked, loop through every object in the report changing its color as you go. Then regenerate the report to the previewer.
Download: ChangeReportColor.zip
Sample Delphi code:
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 |
procedure TmyChangeReportColorPreview.UpdatePageColor; var lPage: TppPage; lDrawText: TppDrawText; liIndex: Integer; begin if (FColor = -1) then Exit; lPage := Viewer.CurrentPage; for liIndex := 0 to lPage.DrawCommandCount - 1 do begin if (lPage.DrawCommands[liIndex] is TppDrawText) then begin lDrawText := TppDrawText(lPage.DrawCommands[liIndex]); lDrawText.Font.Color := FColor; end; end; Viewer.ScreenDevice.RenderPage; Viewer.RefreshPage; end; procedure TmyChangeReportColorPreview.UpdateReportColor; var liBand: Integer; liObject: Integer; lObject: TppComponent; lReport: TppReport; begin if (FColor = -1) then Exit; lReport := TppReport(Viewer.Report); for liBand := 0 to lReport.BandCount-1 do begin for liObject := 0 to lReport.Bands[liBand].ObjectCount-1 do begin lObject := lReport.Bands[liBand].Objects[liObject]; if lObject.HasFont then lObject.Font.Color := FColor; end; end; end; |