Einzelnen Beitrag anzeigen

GreenHorn3600

Registriert seit: 24. Jun 2007
165 Beiträge
 
#13

Re: RTF Linespacing speichern und wiederherstellen

  Alt 26. Okt 2008, 09:47
Mhhh,

wenn ich das so mache, dann zeigt mir das RTF (beim Load) gar nix mehr an

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, richedit, StdCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    bStore: TButton;
    bLoad: TButton;
    bFormat: TButton;
    re: TRichEdit;
    procedure bStoreClick(Sender: TObject);
    procedure bLoadClick(Sender: TObject);
    procedure bFormatClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
    aString: string;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.bFormatClick(Sender: TObject);
var
  aparaformat2 : TParaFormat2;
begin
  ZeroMemory(@aparaformat2, sizeof(aparaformat2));
  aparaformat2.cbSize := SizeOf(aparaformat2);
  aparaformat2.dwMask := PFM_LINESPACING;
  aparaformat2.bLineSpacingRule := 2;
  SendMessage(re.Handle, EM_SETPARAFORMAT, 0, LParam(@aparaformat2));
end;

procedure TForm1.bLoadClick(Sender: TObject);
var
  ss: TStringStream;
begin
  ss := TStringStream.Create;
  try
    ss.WriteString(aString);
    re.Lines.LoadFromStream(ss);
  finally
    ss.Free;
  end;
// re.Lines.LoadFromFile(ChangeFileExt(Application.ExeName, '.txt'));
end;

procedure TForm1.bStoreClick(Sender: TObject);
var
  ss: TStringStream;
begin
  ss := TStringStream.Create;
  try
    re.Lines.SaveToStream(ss);
    aString := aString;
  finally
    ss.Free;
  end;
// re.Lines.SaveToFile(ChangeFileExt(Application.ExeName, '.txt'));
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  re.PlainText := false;
end;

end.
  Mit Zitat antworten Zitat