Einzelnen Beitrag anzeigen

michaelg

Registriert seit: 20. Apr 2008
87 Beiträge
 
#2

Re: Mehr zeiliger Text(Ansi-String) in Richedit

  Alt 27. Jun 2008, 03:56
Probier mal das:

Delphi-Quellcode:
  const //oder "var", je nach Delphi-Version
    StdRichFont:String='Arial';
    StdRichSize:Integer=11;
    StdRichStyle:tFontStyles=[];
    StdRichColor:tColor=clBlack;

  procedure SetRichEditText(RichEdit:tRichEdit; Text:String);
    var
      ms:tMemoryStream;
    begin
      if comparetext('{\RTF',copy(text,1,5))<>0 then begin
        RichEdit.Text:=Text;
        RichEdit.SelectAll;
        RichEdit.SelAttributes.Name:=StdRichFont;
        RichEdit.SelAttributes.Size:=StdRichSize;
        RichEdit.SelAttributes.Style:=StdRichStyle;
        RichEdit.SelAttributes.Color:=StdRichColor;
        RichEdit.Paragraph.FirstIndent:=0;
        RichEdit.Paragraph.LeftIndent:=0;
        RichEdit.Paragraph.Numbering:=nsNone;
        RichEdit.Paragraph.RightIndent:=0;
        RichEdit.Paragraph.TabCount:=0;
      end else begin
        ms:=tMemoryStream.Create;
        ms.Write(Text[1],Length(Text));
        ms.Position:=0;
        RichEdit.PlainText:=False;
        RichEdit.Lines.LoadFromStream(ms);
        ms.Free;
      end;
      RichEdit.SelStart:=0;
      RichEdit.SelLength:=0;
    end;
  Mit Zitat antworten Zitat