dde.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/msw/dde.h
  3. // Purpose: DDE class
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created: 01/02/97
  7. // Copyright: (c) Julian Smart
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_DDE_H_
  11. #define _WX_DDE_H_
  12. #include "wx/ipcbase.h"
  13. /*
  14. * Mini-DDE implementation
  15. Most transactions involve a topic name and an item name (choose these
  16. as befits your application).
  17. A client can:
  18. - ask the server to execute commands (data) associated with a topic
  19. - request data from server by topic and item
  20. - poke data into the server
  21. - ask the server to start an advice loop on topic/item
  22. - ask the server to stop an advice loop
  23. A server can:
  24. - respond to execute, request, poke and advice start/stop
  25. - send advise data to client
  26. Note that this limits the server in the ways it can send data to the
  27. client, i.e. it can't send unsolicited information.
  28. *
  29. */
  30. class WXDLLIMPEXP_FWD_BASE wxDDEServer;
  31. class WXDLLIMPEXP_FWD_BASE wxDDEClient;
  32. class WXDLLIMPEXP_BASE wxDDEConnection : public wxConnectionBase
  33. {
  34. public:
  35. wxDDEConnection(void *buffer, size_t size); // use external buffer
  36. wxDDEConnection(); // use internal buffer
  37. virtual ~wxDDEConnection();
  38. // implement base class pure virtual methods
  39. virtual const void *Request(const wxString& item,
  40. size_t *size = NULL,
  41. wxIPCFormat format = wxIPC_TEXT);
  42. virtual bool StartAdvise(const wxString& item);
  43. virtual bool StopAdvise(const wxString& item);
  44. virtual bool Disconnect();
  45. protected:
  46. virtual bool DoExecute(const void *data, size_t size, wxIPCFormat format);
  47. virtual bool DoPoke(const wxString& item, const void *data, size_t size,
  48. wxIPCFormat format);
  49. virtual bool DoAdvise(const wxString& item, const void *data, size_t size,
  50. wxIPCFormat format);
  51. public:
  52. wxString m_topicName;
  53. wxDDEServer* m_server;
  54. wxDDEClient* m_client;
  55. WXHCONV m_hConv;
  56. const void* m_sendingData;
  57. int m_dataSize;
  58. wxIPCFormat m_dataType;
  59. wxDECLARE_NO_COPY_CLASS(wxDDEConnection);
  60. DECLARE_DYNAMIC_CLASS(wxDDEConnection)
  61. };
  62. class WXDLLIMPEXP_BASE wxDDEServer : public wxServerBase
  63. {
  64. public:
  65. wxDDEServer();
  66. bool Create(const wxString& server_name);
  67. virtual ~wxDDEServer();
  68. virtual wxConnectionBase *OnAcceptConnection(const wxString& topic);
  69. // Find/delete wxDDEConnection corresponding to the HCONV
  70. wxDDEConnection *FindConnection(WXHCONV conv);
  71. bool DeleteConnection(WXHCONV conv);
  72. wxString& GetServiceName() const { return (wxString&) m_serviceName; }
  73. wxDDEConnectionList& GetConnections() const
  74. { return (wxDDEConnectionList&) m_connections; }
  75. protected:
  76. int m_lastError;
  77. wxString m_serviceName;
  78. wxDDEConnectionList m_connections;
  79. DECLARE_DYNAMIC_CLASS(wxDDEServer)
  80. };
  81. class WXDLLIMPEXP_BASE wxDDEClient: public wxClientBase
  82. {
  83. public:
  84. wxDDEClient();
  85. virtual ~wxDDEClient();
  86. bool ValidHost(const wxString& host);
  87. // Call this to make a connection. Returns NULL if cannot.
  88. virtual wxConnectionBase *MakeConnection(const wxString& host,
  89. const wxString& server,
  90. const wxString& topic);
  91. // Tailor this to return own connection.
  92. virtual wxConnectionBase *OnMakeConnection();
  93. // Find/delete wxDDEConnection corresponding to the HCONV
  94. wxDDEConnection *FindConnection(WXHCONV conv);
  95. bool DeleteConnection(WXHCONV conv);
  96. wxDDEConnectionList& GetConnections() const
  97. { return (wxDDEConnectionList&) m_connections; }
  98. protected:
  99. int m_lastError;
  100. wxDDEConnectionList m_connections;
  101. DECLARE_DYNAMIC_CLASS(wxDDEClient)
  102. };
  103. void WXDLLIMPEXP_BASE wxDDEInitialize();
  104. void WXDLLIMPEXP_BASE wxDDECleanUp();
  105. #endif // _WX_DDE_H_