So wird zumindest ein brauchbarer RTF-Code erzeugt:
Delphi-Quellcode:
procedure TFmain.TntButton_generate_ReportClick(Sender: TObject);
var
i, j: Integer;
st1, st2:
String;
StrS: TStringStream;
col: TColor;
begin
StrS := TStringStream.Create('
');
j := ListBox_HEX.Items.Count - 1;
st1 := '
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Courier New;}}';
StrS.WriteString(st1);
st1 := '
{\colortbl ;\red255\green0\blue0;\red0\green0\blue255;}';
StrS.WriteString(st1);
try
for i:= 0
to j
do
begin
st1 := ListBox_HEX.Items[i];
col := TColor(ListBox_HEX.Items.Objects[i]);
case col
of
clRED : st2 := '
\cf1 ';
clBLUE : st2 := '
\cf2 ';
else st2 := '
\cf0 ';
end;
StrS.WriteString(st2 + st1 + '
\par');
end;
st1 := '
}';
StrS.WriteString(st1);
StrS.Position := 0;
RichEdit1.Lines.LoadFromStream(StrS);
finally
StrS.Free;
end;
end;