I want to add some simple reports to my application. For this I want to write a procedure to add text with some attributes. This is my code:
procedure TmDLMain.AddText
ParNumber: Integer; // Paragraph number
NewPage: Boolean; // Insert new Page bevor text add
FontName: String; // Font for text
FontSize: Integer; // Size for text
Color: TColor; // Color of the text
Text: String // Text to Add ...
);
begin
if NewPage = True then RichText.InputString(#12); // New Page
RichText.CPParNr := ParNumber;
RichText.ActiveParagraph.ClearText;
RichText.WritingAttr.SetColor(Color);
RichText.WritingAttr.SetFontName(FontName);
RichText.WritingAttr.SetFontSize(FontSize);
RichText.InputString(Text);
end;
Is this the correct way to add text or is there a better solution?
procedure TmDLMain.AddText(
ParNumber: Integer; // Paragraph number
NewPage: Boolean; // Insert new Page bevor text add
FontName: String; // Font for text
FontSize: Integer; // Size for text
Color: TColor; // Color of the text
Text: String // Text to Add ...
);
begin
if NewPage = True then RichText.InputString(#12); // New Page
RichText.ActiveParagraph.ClearText;
RichText.WritingAttr.SetColor(Color);
RichText.WritingAttr.SetFontName(FontName);
RichText.WritingAttr.SetFontSize(FontSize);
RichText.InputString(Text);
end;
procedure TmDLMain.TBXItem2Click(Sender: TObject);
begin
RichText.Clear;
AddText(0, False, 'Courier New', 9, clGreen, '123456789012345678901234567890');
AddText(1, False, 'Courier New', 9, clRed, 'HalloWelt"!');
end;
The result is online 'HalloWelt"! . I can´t see 1234567........
Is there something missing to begin a new paragraph?!