]>
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
15 wxDDEClient object, or by the acceptance of a connection by a
16 wxDDEServer object. The bulk of a DDE (Dynamic Data Exchange)
17 conversation is controlled by
18 calling members in a @b wxDDEConnection object or by overriding its
21 An application should normally derive a new connection class from
22 wxDDEConnection, in order to override the communication event handlers
23 to do something interesting.
25 This DDE-based implementation is available on Windows only,
26 but a platform-independent, socket-based version
27 of this API is available using wxTCPConnection.
32 @see wxDDEClient, wxDDEServer, @ref overview_ipcoverview "Interprocess
33 communications overview"
35 class wxDDEConnection
: public wxObject
40 Constructs a connection object. If no user-defined connection object is
41 to be derived from wxDDEConnection, then the constructor should not be
42 called directly, since the default connection object will be provided on
43 requesting (or accepting) a connection. However, if the user defines his
44 or her own derived connection object, the wxDDEServer::OnAcceptConnection
45 and/or wxDDEClient::OnMakeConnection members should be replaced by
46 functions which construct the new connection object. If the arguments of
47 the wxDDEConnection constructor are void, then a default buffer is
48 associated with the connection. Otherwise, the programmer must provide a
49 a buffer and size of the buffer for the connection object to use in
53 wxDDEConnection(void* buffer
, size_t size
);
58 Called by the server application to advise the client of a change in
59 the data associated with the given item. Causes the client
60 connection's OnAdvise()
61 member to be called. Returns @true if successful.
63 bool Advise(const wxString
& item
, const void* data
, size_t size
,
64 wxIPCFormat format
= wxIPC_PRIVATE
);
65 bool Advise(const wxString
& item
, const char* data
);
66 bool Advise(const wxString
& item
, const wchar_t* data
);
67 bool Advise(const wxString
& item
, const wxString data
);
71 Called by the client or server application to disconnect from the other
72 program; it causes the OnDisconnect() message
73 to be sent to the corresponding connection object in the other
74 program. The default behaviour of @b OnDisconnect is to delete the
75 connection, but the calling application must explicitly delete its
76 side of the connection having called @b Disconnect. Returns @true if
83 Called by the client application to execute a command on the server. Can
84 also be used to transfer arbitrary data to the server (similar
85 to Poke() in that respect). Causes the
86 server connection's OnExecute() member to be
87 called. Returns @true if successful.
89 bool Execute(const void* data
, size_t size
,
90 wxIPCFormat format
= wxIPC_PRIVATE
);
91 bool Execute(const char* data
);
92 bool Execute(const wchar_t* data
);
93 bool Execute(const wxString data
);
97 Message sent to the client application when the server notifies it of a
98 change in the data associated with the given item.
100 virtual bool OnAdvise(const wxString
& topic
,
101 const wxString
& item
,
107 Message sent to the client or server application when the other
108 application notifies it to delete the connection. Default behaviour is
109 to delete the connection object.
111 virtual bool OnDisconnect();
114 Message sent to the server application when the client notifies it to
115 execute the given data. Note that there is no item associated with
118 virtual bool OnExecute(const wxString
& topic
, const void* data
,
123 Message sent to the server application when the client notifies it to
124 accept the given data.
126 virtual bool OnPoke(const wxString
& topic
, const wxString
& item
,
132 Message sent to the server application when the client
133 calls Request(). The server
134 should respond by returning a character string from @b OnRequest,
135 or @NULL to indicate no data.
137 virtual const void* OnRequest(const wxString
& topic
,
138 const wxString
& item
,
143 Message sent to the server application by the client, when the client
144 wishes to start an 'advise loop' for the given topic and item. The
145 server can refuse to participate by returning @false.
147 virtual bool OnStartAdvise(const wxString
& topic
,
148 const wxString
& item
);
151 Message sent to the server application by the client, when the client
152 wishes to stop an 'advise loop' for the given topic and item. The
153 server can refuse to stop the advise loop by returning @false, although
154 this doesn't have much meaning in practice.
156 virtual bool OnStopAdvise(const wxString
& topic
,
157 const wxString
& item
);
161 Called by the client application to poke data into the server. Can be
162 used to transfer arbitrary data to the server. Causes the server
163 connection's OnPoke() member
164 to be called. Returns @true if successful.
166 bool Poke(const wxString
& item
, const void* data
, size_t size
,
167 wxIPCFormat format
= wxIPC_PRIVATE
);
168 bool Poke(const wxString
& item
, const char* data
);
169 bool Poke(const wxString
& item
, const wchar_t* data
);
170 bool Poke(const wxString
& item
, const wxString data
);
174 Called by the client application to request data from the server. Causes
175 the server connection's OnRequest() member to be called. Returns a
176 character string (actually a pointer to the connection's buffer) if
177 successful, @NULL otherwise.
179 const void* Request(const wxString
& item
, size_t* size
,
180 wxIPCFormat format
= wxIPC_TEXT
);
183 Called by the client application to ask if an advise loop can be started
184 with the server. Causes the server connection's OnStartAdvise()
185 member to be called. Returns @true if the server okays it, @false
188 bool StartAdvise(const wxString
& item
);
191 Called by the client application to ask if an advise loop can be
192 stopped. Causes the server connection's OnStopAdvise() member
193 to be called. Returns @true if the server okays it, @false otherwise.
195 bool StopAdvise(const wxString
& item
);
204 A wxDDEClient object represents the client part of a client-server DDE
205 (Dynamic Data Exchange) conversation.
207 To create a client which can communicate with a suitable server,
208 you need to derive a class from wxDDEConnection and another from wxDDEClient.
209 The custom wxDDEConnection class will intercept communications in
210 a 'conversation' with a server, and the custom wxDDEServer is required
211 so that a user-overridden wxDDEClient::OnMakeConnection member can return
212 a wxDDEConnection of the required class, when a connection is made.
214 This DDE-based implementation is
215 available on Windows only, but a platform-independent, socket-based version
216 of this API is available using wxTCPClient.
221 @see wxDDEServer, wxDDEConnection, @ref overview_ipcoverview "Interprocess
222 communications overview"
224 class wxDDEClient
: public wxObject
228 Constructs a client object.
233 Tries to make a connection with a server specified by the host
234 (machine name under UNIX, ignored under Windows), service name (must
235 contain an integer port number under UNIX), and topic string. If the
236 server allows a connection, a wxDDEConnection object will be returned.
237 The type of wxDDEConnection returned can be altered by overriding
238 the OnMakeConnection() member to return your own
239 derived connection object.
241 wxConnectionBase
* MakeConnection(const wxString
& host
,
242 const wxString
& service
,
243 const wxString
& topic
);
246 The type of wxDDEConnection returned from a MakeConnection() call can
247 be altered by deriving the @b OnMakeConnection member to return your
248 own derived connection object. By default, a wxDDEConnection
250 The advantage of deriving your own connection class is that it will
251 enable you to intercept messages initiated by the server, such
252 as wxDDEConnection::OnAdvise. You may also want to
253 store application-specific data in instances of the new class.
255 wxConnectionBase
* OnMakeConnection();
258 Returns @true if this is a valid host name, @false otherwise. This always
259 returns @true under MS Windows.
261 bool ValidHost(const wxString
& host
);
270 A wxDDEServer object represents the server part of a client-server DDE
271 (Dynamic Data Exchange) conversation.
273 This DDE-based implementation is
274 available on Windows only, but a platform-independent, socket-based version
275 of this API is available using wxTCPServer.
280 @see wxDDEClient, wxDDEConnection, @ref overview_ipcoverview "IPC overview"
286 Constructs a server object.
291 Registers the server using the given service name. Under UNIX, the
292 string must contain an integer id which is used as an Internet port
293 number. @false is returned if the call failed (for example, the port
294 number is already in use).
296 bool Create(const wxString
& service
);
299 When a client calls @b MakeConnection, the server receives the
300 message and this member is called. The application should derive a
301 member to intercept this message and return a connection object of
302 either the standard wxDDEConnection type, or of a user-derived type. If the
303 topic is "STDIO", the application may wish to refuse the connection.
304 Under UNIX, when a server is created the OnAcceptConnection message is
305 always sent for standard input and output, but in the context of DDE
306 messages it doesn't make a lot of sense.
308 virtual wxConnectionBase
* OnAcceptConnection(const wxString
& topic
);
313 // ============================================================================
314 // Global functions/macros
315 // ============================================================================
317 /** @ingroup group_funcmacro_misc */
321 Called when wxWidgets exits, to clean up the DDE system. This no longer
322 needs to be called by the application.
324 @see wxDDEInitialize()
331 Initializes the DDE system. May be called multiple times without harm.
333 This no longer needs to be called by the application: it will be called by
334 wxWidgets if necessary.
336 @see wxDDEServer, wxDDEClient, wxDDEConnection, wxDDECleanUp()
340 void wxDDEInitialize();