unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls;
type
TForm1 =
class(TForm)
RichEdit1: TRichEdit;
RichEdit2: TRichEdit;
Button1: TButton;
OpenDialog1: TOpenDialog;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
// Beispieltext speichern.
var
Memo1: TMemo;
begin
SaveDialog1.FileName:= '
C:\Temp\Text.rtf';
OpenDialog1.FileName:= SaveDialog1.FileName;
Memo1.Create;
Memo1.Lines.Add('
{\rtf1\ansi\ansicpg1252\uc1 '
//Header mit Codepage
+ '
{\colortbl;\red0\green0\blue0;\red255\green0\blue0;} '
//Farbtabelle
+ '
{Ein }{\ul formatierter}{ }{\b Text}{ in }{\cf2 RTF} '
//Text mit Formatierung
+ '
{\par }}');
//Absatzmarke
Memo1.Lines.SaveToFile(OpenDialog.FileName);
Memo1.Free;
end;
procedure TForm1.Button1Click(Sender: TObject);
// Beispieltext laden, also das eigentliche Beispiel.
begin
if OpenDialog1.Execute
then
begin
Richedit1.PlainText:= True;
// Format ignorieren
RichEdit1.Lines.LoadFromFile(OpenDialog1.FileName);
Richedit2.PlainText:= False;
// Format behalten
RichEdit1.Lines.LoadFromFile(OpenDialog1.FileName);
end;
end;
end.