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?
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?
If Alex's answer is not what you are looking for, then please tell us what the problem is.
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(Serve r);
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.
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(Serve
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Just do it like you had descibed it in your first question, but use
TStrings(p^) := Server.STRINGS[0];
instead of
TStrings(p^) := Server;
TStrings(p^) := Server.STRINGS[0];
instead of
TStrings(p^) := Server;
ASKER
I have just returned from a trip, i will evaluate your comments tonight.
sorry about the delay(zzzzzzzZZZZzz);
//raidos
sorry about the delay(zzzzzzzZZZZzz);
//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
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
ASKER
Comment accepted as answer
>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.line
That will do the job, if that's what you want.
Alex