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