Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 May : Making server interact with GUI

www.cryer.info
Managed Newsgroup Archive

Making server interact with GUI

Subject:Making server interact with GUI
Posted by:"John Carlyle-Clarke" (jpcc@removethis.bigfoot.com)
Date:11 May 2006 09:26:57

This may be an easy/obvious question, but I just can't quite get it
and none of the demo's seem to help.

My app is based on a multithreaded "OnExecute" TCP server.  It is
designed to test remote GPRS units which have a simple text protocol.
For each unit that connects, I want a form with a memo showing
incoming text lines, and the ability to send a text string back to it.

I have the first part working - using a custom message in the
OnConnect event, I get a secondary form created and pass it the
context.

The context.data has a class of my own which has the hwnd of the form,
so when ReadLn returns in the Execute event I get the window handle
from context.data and send a message to it to display the text.

So far so good.

What I can't work out is how to respond to the user pressing the
"Send" button on my connection form, to send text back to the remote
unit.

I can't just call context.connection.IOHandler.write in the button
event, because that would block the GUI.

Surely I want to do the writing in the same thread that the reading is
done in.  How can I achieve this?  Seems to me like I want to send a
message back to the thread, but I'm not sure where to get the threadID
or how to trap that message within the thread object.  Or am totally
barking up the wrong tree?

Any clue to get me going would be good.

Thanks in advance.

Replies:

www.cryer.info
Managed Newsgroup Archive