Page 1 of 1

Send RichViewEdit Text though a Socket?

Posted: Sat Feb 18, 2006 7:54 pm
by parad0x
How is it possible to send RichViewEdit text through a Client Socket?

I am trying to design a Chat program through TCP/IP

Any advice would be welcome, a small example would be excellent!

Many thanks.

ps: TRichViewEdit & TRichView are the best Components available, I don't think anything even comes close to them.

Posted: Sat Feb 18, 2006 9:04 pm
by Rob
I would not send RV-Internal objects but use a serializer and deserializer to send text and object through a socket.
There are plenty of examples out there that hint you on how to implement serialization. Here you have one example for an XML Serializer:

http://www.dragonsoftru.com/delphi_vcl.php

Posted: Sun Feb 19, 2006 7:07 am
by parad0x
Hi,

Thank you very much for replying. I think the serializer is way beyond me at the moment, I am just a novice!

I am using the ICS Components, with two WSockets, one as a Server and another as the Client.

I have managed to get the text sent through by using:

Code: Select all

CliSock.LineMode := True;
CliSock.SendStr(RichViewEdit2.RVData.Items.Text + #13#10);
RichView1.AddNL('Local> ' +RichViewEdit2.RVData.Items.Text ,1,0);
RichViewEdit2.FormatTail;
RichView1.FormatTail;
The problem is that this is adding two squares at the end of the text in the RichView like:

Code: Select all

Local> test ◙◙
and in the RichView that I send to in the Remote machine it sends it like:

Code: Select all

Remote> test◙
Remote> ◙
Could somebody please explain how I can send strings from RichView through a socket like it would be done through a Memo, ie: Memo1.Lines.Add('This is a test'); and Memo1.Lines.Text?

Are there any chat programs using TRichViewEdit & TRichView Demos available anywhere that anyone knows of?

Many thanks for helping

Posted: Sun Feb 19, 2006 12:28 pm
by Sergey Tkachenko
Text parameter of AddNL must not contain line break characters.
Actually, they are not needed there if you want to add one line of text, because text is added from the new line any time when StyleNo parameter >= 0.

If you need to add multiline text, use AddTextNL method instead.