Autor Beitrag
motion
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 295

XP, Linux
D7 Prof
BeitragVerfasst: Mi 05.10.05 21:20 
Gibt es irgendwo eine etwas umfangreichede Doku im Netz, welche die Nutzung der RichEdit VCL Komponente beschreibt.
Überall (auch hier im Forum) liegen ein paar Brocken rum, ich suche da mal etwas Ausführlicheres, damit ich den Zugang zur Nutzung hin kriege.

Mein aktuelles Problem ist z.B.:
Wie kopiere ich den RichtText inkl. Formattierungen aus einer Komponente in ein Blob Feld der Datenbank (eine DBRichText Komponenten kann ich in diesem Fall leider nicht verwenden). Geht das nur über ein Stream?
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mi 05.10.05 21:43 
user profile iconmotion hat folgendes geschrieben:
Mein aktuelles Problem ist z.B.:
Wie kopiere ich den RichtText inkl. Formattierungen aus einer Komponente in ein Blob Feld der Datenbank (eine DBRichText Komponenten kann ich in diesem Fall leider nicht verwenden). Geht das nur über ein Stream?

Soviel ich weiss, ja. Über RichEdit1.Text erhält man nur den Text ohne die Formatierungen. Um diese auch zu kopieren, muss man den Umweg über einen Stream gehen. Aber ich meine, dass das auch so in der Delphi-Hilfe steht...

_________________
We are, we were and will not be.
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mi 05.10.05 22:12 
Hallo,
user profile iconmotion hat folgendes geschrieben:
Gibt es irgendwo eine etwas umfangreichede Doku im Netz...

meines Wissens nicht.

Zu deinem aktuellen Problem:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
function GetRTFFromRichEdit(aRichEdit: TRichEdit): String;
var StrS : TStringStream;
begin
  StrS := TStringStream.Create('');
  try
    aRichEdit.Lines.SaveToStream(StrS);
    Result := StrS.DataString;
  finally
    StrS.Free;
  end;
end;

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
motion Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 295

XP, Linux
D7 Prof
BeitragVerfasst: Mi 05.10.05 22:29 
Bingo,
das scheint ein brauchbares Code-Fragment für mein aktuelles Problem zu sein.
ich werd's morgen mal testen.
motion Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 295

XP, Linux
D7 Prof
BeitragVerfasst: Do 06.10.05 09:03 
@Lannes,
jawoll, das hat funktioniert.
Jetzt bleibt nur noch das Restproblem, die Daten aus dem String wieder einzuladen. Okay, das kann man mit LoadfromStream machen, aber wie füttere ich den TStringStream als Zwischenpuffer damit?
Ich habe mal kurz probiert
ausblenden Delphi-Quelltext
1:
2:
3:
        Buffer:=IB_Query1.FieldByName(Spaltenname).asString;
        Strs.Read(Buffer,Length(Buffer)); //Das klappt wohl nicht
        RTF.LoadFromStream(Strs);


Aber das Konstrukt funktioniert leider nicht.
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Do 06.10.05 09:31 
Hallo,

versuch es mal damit: :wink:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure SetRTFToRichEdit(sRTF: String;aRichEdit: TRichEdit);
var StrS : TStringStream;
begin
  StrS := TStringStream.Create('');
  try
    StrS.WriteString(sRTF);
    StrS.Position := 0;
    aRichEdit.Lines.LoadFromStream(StrS);
  finally
    StrS.Free;
  end;
end;

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
motion Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 295

XP, Linux
D7 Prof
BeitragVerfasst: Do 06.10.05 09:58 
Super,
funktioniert wie 'ne eins!