Send RichViewEdit Text though a Socket?

General TRichView support forum. Please post your questions here
Post Reply
parad0x
Posts: 14
Joined: Fri Feb 17, 2006 11:40 pm

Send RichViewEdit Text though a Socket?

Post 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.
Rob
Posts: 52
Joined: Wed Sep 07, 2005 6:47 am

Post 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
parad0x
Posts: 14
Joined: Fri Feb 17, 2006 11:40 pm

Post 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
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
Post Reply