Autor Beitrag
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Sa 11.02.06 19:06 
Hi
ich arbeite mir jetzt schon den ganzen Tag mir die Finger wund, nur damit ich es endlich hinbekomme, in meinen Netzwerkchat (LanChat2 TBX) die Möglichkeit einzubauen, formatierten Text zu übertragen.
Bisher war die Devise: Wir nehmen das RichEdit, wandeln das dann in HTML um, verschicken das dann und auf der anderen Seite wirds wieder vom HTML ins RichEdit eingefügt.
Jedoch ist es so, dass das einfügen bei nur etwa 7-8 unterstüzten Tags bereits unglaublich schwer ist.
Jetzt, nach etlichen Umdenkereien, Kompromissen, die zukünftigen Programmfunktionen im Weg stehen, usw., hab ich langsam keine Lust mehr, mich damit rumzuplagen, da das ganze wieder von vorne losgehen würde, wenn ich auf das TJvRichEdit umsteigen würde (um auch Bilder einfügen zu können).

Leider bekommt man ja aus dem RichEdit nicht direkt den rtf-Text. Nimmt man ganz einfach RichEdit.Text, geht die Formatierung verloren.

Ok, wenn ich Lines.SaveToStream nehme und das ganze dann in ein Memo oder so einfüge, komm ich daran. Also ist das auch nicht mehr mein Problem.

Aber wie füge ich diesen Text jetzt in das andere RichEdit wieder ein?
Weil einfach ein [Delphi]LoadFromStream[/Delphi geht nicht, es ist ja schon vorher in diesem RichEdit, was ja das Chatlog ist, Text drinnen, der dann verloren gehen würde.

Also im Prinzip ist mir jede Lösung recht, hauptsache sie funktioniert gut (und am besten gleich auch mit dem TJvRichEdit)

Gruß alias5000

_________________
Programmers never die, they just GOSUB without RETURN
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Sa 11.02.06 19:57 
In der Dp gabs schon threads dazu, z.B. diesen: www.delphipraxis.net...ic57044,0,asc,0.html

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
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: So 12.02.06 12:02 
Hallo,

:arrow: [RichEdit, VCL Win32] zusammenhängende Doku irgendwo verfügbar?
dort findest Du zwei Routinen die mit einem String arbeiten:
ausblenden Delphi-Quelltext
1:
function GetRTFFromRichEdit(aRichEdit: TRichEdit): String;					
ausblenden Delphi-Quelltext
1:
procedure SetRTFToRichEdit(sRTF: String;aRichEdit: TRichEdit);					

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

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: So 12.02.06 12:20 
Ja also ich hab jetzt mittels der DP ein paar eigene Routinen geschrieben, funktionieren einwandfrei. Man könnte sie evtl. noch ein wenig optimieren (nicht über eine TStringList gehen) aber mir genügt das jetzt erstmal.

Hier die Source der Unit:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
unit rtf2rtf;

interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, JvExStdCtrls, JvRichEdit, ComCtrls, RichEdit;

function FromRTFtoString(var RichEdit: TRichEdit): string; overload;
function FromRTFtoString(var RichEdit: TJvRichEdit): string; overload;
Procedure FromStringIntoRTF(s: string; var RichEdit: TJvRichEdit);


implementation

function FromRTFtoString(var RichEdit: TRichEdit): string; overload;
var stream: TMemoryStream;
sl: TStringList;
begin
Result := '';
if RichEdit = nil then begin
  exit;
end;
Stream := TMemoryStream.Create;
sl := TStringList.Create;
RichEdit.Lines.SaveToStream(Stream);
Stream.Position := 0;
sl.LoadFromStream(Stream);
Result := sl.Text;
sl.Free;
Stream.Free;
end;

function FromRTFtoString(var RichEdit: TJvRichEdit): string; overload;
var stream: TMemoryStream;
sl: TStringList;
begin
Result := '';
if RichEdit = nil then begin
  exit;
end;
Stream := TMemoryStream.Create;
sl := TStringList.Create;
RichEdit.Lines.SaveToStream(Stream);
Stream.Position := 0;
sl.LoadFromStream(Stream);
Result := sl.Text;
sl.Free;
Stream.Free;
end;

Procedure FromStringIntoRTF(s: string; var RichEdit: TJvRichEdit);
var Stream: TMemoryStream;
sl: TStringList;
begin
if (s = '') or (not assigned(RichEdit)) then begin
  exit;
end;
Stream := TMemoryStream.Create;
sl := TStringList.Create;
sl.Text := s;
sl.SaveToStream(Stream);
RichEdit.StreamMode := RichEdit.StreamMode + [smSelection];
Stream.Position := 0;
RichEdit.Lines.LoadFromStream(Stream);
RichEdit.StreamMode := RichEdit.StreamMode - [smSelection];
sl.Free;
Stream.Free;
end;




end.


Gruß alias5000

_________________
Programmers never die, they just GOSUB without RETURN