Principles of DDE
The following describes how wxWindows implements DDE. The following
three classes are crucial.
- wxClient. This represents the client application, and is used
only within a client program.
- wxServer. This represents the server application, and is used
only within a server program.
- wxConnection. This represents the connection from the current
client or server to the other application (server or client), and can be used
in both server and client programs. Most DDE
transactions operate on this object.
Messages between applications are usually identified by three variables:
connection object, topic name and item name. A data string is a fourth
element of some messages. To create a connection (a conversation in
Windows parlance), the client application sends the message
MakeConnection to the client object, with a string service name to
identify the server and a topic name to identify the topic for the
duration of the connection. Under UNIX, the service name must contain an
integer port identifier.
The server then responds and either vetos the connection or allows it.
If allowed, a connection object is created which persists until the
connection is closed. The connection object is then used for subsequent
messages between client and server.
To create a working server, the programmer must:
- Derive a class from wxServer.
- Override the handler OnAcceptConnection for accepting or rejecting a connection,
on the basis of the topic argument. This member must create and return a connection
object if the connection is accepted.
- Create an instance of your server object, and call Create to
activate it, giving it a service name.
- Derive a class from wxConnection.
- Provide handlers for various messages that are sent to the server
side of a wxConnection.
To create a working client, the programmer must:
- Derive a class from wxClient.
- Override the handler OnMakeConnection to create and return
an appropriate connection object.
- Create an instance of your client object.
- Derive a class from wxConnection.
- Provide handlers for various messages that are sent to the client
side of a wxConnection.
- When appropriate, create a new connection by sending a MakeConnection
message to the client object, with arguments host name (processed in UNIX only),
service name, and topic name for this connection. The client object will call OnMakeConnection
to create a connection object of the desired type.
- Use the wxConnection member functions to send messages to the server.