]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/dde.h
Ryan's cumulative wxActiveX and media control patch (1427775)
[wxWidgets.git] / include / wx / msw / dde.h
CommitLineData
2bda0e17
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: dde.h
3// Purpose: DDE class
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
bbcdf8bc 8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
bbcdf8bc
JS
12#ifndef _WX_DDE_H_
13#define _WX_DDE_H_
2bda0e17 14
2bda0e17
KB
15#include "wx/ipcbase.h"
16
17/*
18 * Mini-DDE implementation
19
20 Most transactions involve a topic name and an item name (choose these
21 as befits your application).
22
23 A client can:
24
25 - ask the server to execute commands (data) associated with a topic
26 - request data from server by topic and item
27 - poke data into the server
28 - ask the server to start an advice loop on topic/item
29 - ask the server to stop an advice loop
30
31 A server can:
32
33 - respond to execute, request, poke and advice start/stop
34 - send advise data to client
35
36 Note that this limits the server in the ways it can send data to the
37 client, i.e. it can't send unsolicited information.
38 *
39 */
40
bddd7a8d
VZ
41class WXDLLIMPEXP_BASE wxDDEServer;
42class WXDLLIMPEXP_BASE wxDDEClient;
2bda0e17 43
bddd7a8d 44class WXDLLIMPEXP_BASE wxDDEConnection: public wxConnectionBase
2bda0e17
KB
45{
46 DECLARE_DYNAMIC_CLASS(wxDDEConnection)
b3324be2 47public:
d38e8d5f 48 wxDDEConnection(wxChar *buffer, int size); // use external buffer
b814b812 49 wxDDEConnection(); // use internal buffer
2bda0e17
KB
50 ~wxDDEConnection(void);
51
52 // Calls that CLIENT can make
e90c1d2a 53 virtual bool Execute(const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
0e4acbd4 54 virtual bool Execute(const wxString& str) { return Execute(str, -1, wxIPC_TEXT); }
d38e8d5f 55 virtual wxChar *Request(const wxString& item, int *size = NULL, wxIPCFormat format = wxIPC_TEXT);
32c1cda2 56 virtual bool Poke(const wxString& item, wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
2bda0e17
KB
57 virtual bool StartAdvise(const wxString& item);
58 virtual bool StopAdvise(const wxString& item);
59
60 // Calls that SERVER can make
32c1cda2 61 virtual bool Advise(const wxString& item, wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
2bda0e17
KB
62
63 // Calls that both can make
64 virtual bool Disconnect(void);
65
d71cc120 66 // Default behaviour is to delete connection and return true
2bda0e17 67 virtual bool OnDisconnect(void);
b3324be2
JS
68
69 public:
b3324be2 70 wxString m_topicName;
b3324be2
JS
71 wxDDEServer* m_server;
72 wxDDEClient* m_client;
73
74 WXHCONV m_hConv;
32c1cda2 75 wxChar* m_sendingData;
b3324be2 76 int m_dataSize;
0d2a2b60 77 wxIPCFormat m_dataType;
22f3361e
VZ
78
79 DECLARE_NO_COPY_CLASS(wxDDEConnection)
2bda0e17
KB
80};
81
bddd7a8d 82class WXDLLIMPEXP_BASE wxDDEServer: public wxServerBase
2bda0e17
KB
83{
84 DECLARE_DYNAMIC_CLASS(wxDDEServer)
85 public:
86
87 wxDDEServer(void);
88 ~wxDDEServer(void);
d71cc120 89 bool Create(const wxString& server_name); // Returns false if can't create server (e.g. port
2bda0e17
KB
90 // number is already in use)
91 virtual wxConnectionBase *OnAcceptConnection(const wxString& topic);
92
93 ////////////////////////////////////////////////////////////
94 // Implementation
95
96 // Find/delete wxDDEConnection corresponding to the HCONV
97 wxDDEConnection *FindConnection(WXHCONV conv);
98 bool DeleteConnection(WXHCONV conv);
b3324be2 99 inline wxString& GetServiceName(void) const { return (wxString&) m_serviceName; }
d162a7ee
VZ
100 inline wxDDEConnectionList& GetConnections(void) const
101 {
102 return (wxDDEConnectionList&) m_connections;
103 }
104
105protected:
106 int m_lastError;
107 wxString m_serviceName;
108 wxDDEConnectionList m_connections;
2bda0e17
KB
109};
110
bddd7a8d 111class WXDLLIMPEXP_BASE wxDDEClient: public wxClientBase
2bda0e17
KB
112{
113 DECLARE_DYNAMIC_CLASS(wxDDEClient)
114 public:
115 wxDDEClient(void);
116 ~wxDDEClient(void);
117 bool ValidHost(const wxString& host);
118 virtual wxConnectionBase *MakeConnection(const wxString& host, const wxString& server, const wxString& topic);
119 // Call this to make a connection.
120 // Returns NULL if cannot.
121 virtual wxConnectionBase *OnMakeConnection(void); // Tailor this to return own connection.
122
123 ////////////////////////////////////////////////////////////
124 // Implementation
125
126 // Find/delete wxDDEConnection corresponding to the HCONV
127 wxDDEConnection *FindConnection(WXHCONV conv);
128 bool DeleteConnection(WXHCONV conv);
2bda0e17 129
d162a7ee
VZ
130 inline wxDDEConnectionList& GetConnections(void) const
131 {
132 return (wxDDEConnectionList&) m_connections;
133 }
134
135protected:
136 int m_lastError;
137 wxDDEConnectionList m_connections;
2bda0e17
KB
138};
139
bddd7a8d
VZ
140void WXDLLIMPEXP_BASE wxDDEInitialize();
141void WXDLLIMPEXP_BASE wxDDECleanUp();
2bda0e17 142
2bda0e17 143#endif
bbcdf8bc 144 // _WX_DDE_H_