Link to home
Start Free TrialLog in
Avatar of raidos
raidos

asked on

Assigning TRichedit.Lines to a TStrings variable

Take a look at this code.
ChatWnd is a TRichEdit.

Var
  Server : TStrings;

Procedure DoIt;
Var
  P : Pointer;
Begin
 Server := TStringList.Create;
 P := @ChatWnd.Lines;
 TStrings(P^) := Server;
End;

This makes the "Server" text go into Both Server and ChatWnd.Lines but the
painting or something of ChatWnd seems to never occur anymore,
I am missing something essential.


Any ideas?


Avatar of simonet
simonet
Flag of Brazil image

I don't get it. What do you want to do?

>I am missing something essential.

I think so. The ^ and @ operators are entirely unnecessary there, because all objects are pointers.

Assigning an object to an untyped pointer goes like this:

P := pointer(ChatWnd.lines);


What I don't get it:

in the second line, you are assigning a value to P. Then, on the second line, you again assign a new value to P, losing the previously assigned value.

What exactly are you trying to achieve?

If all you want is to copy ChatWnd.lines to Server, you can do:

Server := TStringList.create;
Server.assign(ChatWnd.lines);


That will do the job, if that's what you want.

Alex

Avatar of xsoft
xsoft

If Alex's answer is not what you are looking for, then please tell us what the problem is.
Avatar of raidos

ASKER

Ok, This is what i want to do

I have an array of TStrings that will contain text,
when i have Activate one of the TStrings then The text previously sent and Sent while TStrings object is active should come up in The RichEdit

IE:
 Something like this:
 Server := TStringList.create;
 ChatWnd.Lines.assign(Server);

 With autoupdate of
   ChatWnd.Lines from Server

Sorry about the mess...
I have to little experience to try and do something like this.

Bahhh...
I hope this will clarify a few of my thoughts and intentions.
ASKER CERTIFIED SOLUTION
Avatar of EdHillmann
EdHillmann

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Just do it like you had descibed it in your first question, but use
TStrings(p^) := Server.STRINGS[0];
instead of
TStrings(p^) := Server;

Avatar of raidos

ASKER

I have just returned from a trip, i will evaluate your comments tonight.

sorry about the delay(zzzzzzzZZZZzz);


//raidos
Avatar of raidos

ASKER

Thank you for your comments,
I think i will have to go with Eds comment although it's not exactly what I asked for.

If any of you disagree with that, please respond before 10 AM(GMT) tomorrow.

Thanks again

//raidos

Avatar of raidos

ASKER

Comment accepted as answer