]>
git.saurik.com Git - wxWidgets.git/blob - interface/dde.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxDDEConnection
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxDDEConnection
13 A wxDDEConnection object represents the connection between a client and a
14 server. It can be created by making a connection using a wxDDEClient
15 object, or by the acceptance of a connection by a wxDDEServer object. The
16 bulk of a DDE (Dynamic Data Exchange) conversation is controlled by calling
17 members in a wxDDEConnection object or by overriding its members.
19 An application should normally derive a new connection class from
20 wxDDEConnection, in order to override the communication event handlers to
21 do something interesting.
23 This DDE-based implementation is available on Windows only, but a
24 platform-independent, socket-based version of this API is available using
30 @see wxConnectionBase, wxDDEClient, wxDDEServer, @ref overview_ipc
32 class wxDDEConnection
: public wxConnectionBase
36 Constructs a connection object. If no user-defined connection object is
37 to be derived from wxDDEConnection, then the constructor should not be
38 called directly, since the default connection object will be provided
39 on requesting (or accepting) a connection. However, if the user defines
40 his or her own derived connection object, the
41 wxDDEServer::OnAcceptConnection() and/or
42 wxDDEClient::OnMakeConnection() members should be replaced by functions
43 which construct the new connection object.
45 A default buffer will be associated with this connection.
49 Constructs a connection object. If no user-defined connection object is
50 to be derived from wxDDEConnection, then the constructor should not be
51 called directly, since the default connection object will be provided
52 on requesting (or accepting) a connection. However, if the user defines
53 his or her own derived connection object, the
54 wxDDEServer::OnAcceptConnection() and/or
55 wxDDEClient::OnMakeConnection() members should be replaced by functions
56 which construct the new connection object.
59 Buffer for this connection object to use in transactions.
61 Size of the buffer given.
63 wxDDEConnection(void* buffer
, size_t size
);
67 Called by the server application to advise the client of a change in
68 the data associated with the given item. Causes the client connection's
69 OnAdvise() member to be called.
71 @returns @true if successful.
73 bool Advise(const wxString
& item
, const void* data
, size_t size
,
74 wxIPCFormat format
= wxIPC_PRIVATE
);
75 bool Advise(const wxString
& item
, const char* data
);
76 bool Advise(const wxString
& item
, const wchar_t* data
);
77 bool Advise(const wxString
& item
, const wxString data
);
81 Called by the client or server application to disconnect from the other
82 program; it causes the OnDisconnect() message to be sent to the
83 corresponding connection object in the other program. The default
84 behaviour of OnDisconnect() is to delete the connection, but the
85 calling application must explicitly delete its side of the connection
86 having called Disconnect().
88 @returns @true if successful.
94 Called by the client application to execute a command on the server.
95 Can also be used to transfer arbitrary data to the server (similar to
96 Poke() in that respect). Causes the server connection's OnExecute()
99 @returns @true if successful.
101 bool Execute(const void* data
, size_t size
,
102 wxIPCFormat format
= wxIPC_PRIVATE
);
103 bool Execute(const char* data
);
104 bool Execute(const wchar_t* data
);
105 bool Execute(const wxString data
);
109 Message sent to the client application when the server notifies it of a
110 change in the data associated with the given item.
112 virtual bool OnAdvise(const wxString
& topic
, const wxString
& item
,
113 const void* data
, size_t size
, wxIPCFormat format
);
116 Message sent to the client or server application when the other
117 application notifies it to delete the connection. Default behaviour is
118 to delete the connection object.
120 virtual bool OnDisconnect();
123 Message sent to the server application when the client notifies it to
124 execute the given data. Note that there is no item associated with
127 virtual bool OnExecute(const wxString
& topic
, const void* data
,
128 size_t size
, wxIPCFormat format
);
131 Message sent to the server application when the client notifies it to
132 accept the given data.
134 virtual bool OnPoke(const wxString
& topic
, const wxString
& item
,
135 const void* data
, size_t size
, wxIPCFormat format
);
138 Message sent to the server application when the client calls Request().
139 The server should respond by returning a character string from
140 OnRequest(), or @NULL to indicate no data.
142 virtual const void* OnRequest(const wxString
& topic
,
143 const wxString
& item
, size_t* size
,
147 Message sent to the server application by the client, when the client
148 wishes to start an "advise loop" for the given topic and item. The
149 server can refuse to participate by returning @false.
151 virtual bool OnStartAdvise(const wxString
& topic
, const wxString
& item
);
154 Message sent to the server application by the client, when the client
155 wishes to stop an "advise loop" for the given topic and item. The
156 server can refuse to stop the advise loop by returning @false, although
157 this doesn't have much meaning in practice.
159 virtual bool OnStopAdvise(const wxString
& topic
, const wxString
& item
);
163 Called by the client application to poke data into the server. Can be
164 used to transfer arbitrary data to the server. Causes the server
165 connection's OnPoke() member to be called.
167 @returns @true if successful.
169 bool Poke(const wxString
& item
, const void* data
, size_t size
,
170 wxIPCFormat format
= wxIPC_PRIVATE
);
171 bool Poke(const wxString
& item
, const char* data
);
172 bool Poke(const wxString
& item
, const wchar_t* data
);
173 bool Poke(const wxString
& item
, const wxString data
);
177 Called by the client application to request data from the server.
178 Causes the server connection's OnRequest() member to be called.
180 @returns A character string (actually a pointer to the connection's
181 buffer) if successful, @NULL otherwise.
183 const void* Request(const wxString
& item
, size_t* size
,
184 wxIPCFormat format
= wxIPC_TEXT
);
187 Called by the client application to ask if an advise loop can be
188 started with the server. Causes the server connection's OnStartAdvise()
191 @returns @true if the server okays it, @false otherwise.
193 bool StartAdvise(const wxString
& item
);
196 Called by the client application to ask if an advise loop can be
197 stopped. Causes the server connection's OnStopAdvise() member to be
200 @returns @true if the server okays it, @false otherwise.
202 bool StopAdvise(const wxString
& item
);
211 A wxDDEClient object represents the client part of a client-server DDE
212 (Dynamic Data Exchange) conversation.
214 To create a client which can communicate with a suitable server, you need
215 to derive a class from wxDDEConnection and another from wxDDEClient. The
216 custom wxDDEConnection class will intercept communications in a
217 "conversation" with a server, and the custom wxDDEServer is required so
218 that a user-overridden OnMakeConnection() member can return a
219 wxDDEConnection of the required class, when a connection is made.
221 This DDE-based implementation is available on Windows only, but a
222 platform-independent, socket-based version of this API is available using
228 @see wxDDEServer, wxDDEConnection, @ref overview_ipc
230 class wxDDEClient
: public wxObject
234 Constructs a client object.
239 Tries to make a connection with a server specified by the host (machine
240 name under UNIX, ignored under Windows), service name (must contain an
241 integer port number under UNIX), and topic string. If the server allows
242 a connection, a wxDDEConnection object will be returned.
244 The type of wxDDEConnection returned can be altered by overriding the
245 OnMakeConnection() member to return your own derived connection object.
247 wxConnectionBase
* MakeConnection(const wxString
& host
,
248 const wxString
& service
,
249 const wxString
& topic
);
252 The type of wxDDEConnection returned from a MakeConnection() call can
253 be altered by deriving the OnMakeConnection() member to return your own
254 derived connection object. By default, a wxDDEConnection object is
257 The advantage of deriving your own connection class is that it will
258 enable you to intercept messages initiated by the server, such as
259 wxDDEConnection::OnAdvise(). You may also want to store
260 application-specific data in instances of the new class.
262 wxConnectionBase
* OnMakeConnection();
265 Returns @true if this is a valid host name, @false otherwise. This
266 always returns @true under MS Windows.
268 bool ValidHost(const wxString
& host
);
277 A wxDDEServer object represents the server part of a client-server DDE
278 (Dynamic Data Exchange) conversation.
280 This DDE-based implementation is available on Windows only, but a
281 platform-independent, socket-based version of this API is available using
287 @see wxDDEClient, wxDDEConnection, @ref overview_ipc
293 Constructs a server object.
298 Registers the server using the given service name. Under UNIX, the
299 string must contain an integer id which is used as an Internet port
300 number. @false is returned if the call failed (for example, if the port
301 number is already in use).
303 bool Create(const wxString
& service
);
306 When a client calls wxDDEClient::MakeConnection(), the server receives
307 the message and this member is called. The application should derive a
308 member to intercept this message and return a connection object of
309 either the standard wxDDEConnection type, or of a user-derived type.
311 If the @a topic is "STDIO", the application may wish to refuse the
312 connection. Under UNIX, when a server is created the
313 OnAcceptConnection() message is always sent for standard input and
314 output, but in the context of DDE messages it doesn't make a lot of
317 virtual wxConnectionBase
* OnAcceptConnection(const wxString
& topic
);
322 // ============================================================================
323 // Global functions/macros
324 // ============================================================================
326 /** @ingroup group_funcmacro_misc */
330 Called when wxWidgets exits, to clean up the DDE system. This no longer
331 needs to be called by the application.
333 @see wxDDEInitialize()
340 Initializes the DDE system. May be called multiple times without harm.
342 This no longer needs to be called by the application: it will be called by
343 wxWidgets if necessary.
345 @see wxDDEServer, wxDDEClient, wxDDEConnection, wxDDECleanUp()
349 void wxDDEInitialize();