+ if (GetServername()->GetStringSelection() == _T("..."))
+ {
+ wxString s = wxGetTextFromUser(_T("Specify the name of the server"),
+ _T("Server Name"), wxEmptyString, this);
+ if (!s.IsEmpty() && s != IPC_SERVICE)
+ {
+ GetServername()->Insert(s, 0);
+ GetServername()->SetSelection(0);
+ }
+ }
+}
+
+void MyFrame::OnHostname( wxCommandEvent& WXUNUSED(event) )
+{
+ if (GetHostname()->GetStringSelection() == _T("..."))
+ {
+ wxString s = wxGetTextFromUser(_T("Specify the name of the host (ignored under DDE)"),
+ _T("Host Name"), wxEmptyString, this);
+ if (!s.IsEmpty() && s != IPC_HOST)
+ {
+ GetHostname()->Insert(s, 0);
+ GetHostname()->SetSelection(0);
+ }
+ }
+}
+
+void MyFrame::OnTopic( wxCommandEvent& WXUNUSED(event) )
+{
+ if (GetTopic()->GetStringSelection() == _T("..."))
+ {
+ wxString s = wxGetTextFromUser(_T("Specify the name of the topic"),
+ _T("Topic Name"), wxEmptyString, this);
+ if (!s.IsEmpty() && s != IPC_TOPIC)
+ {
+ GetTopic()->Insert(s, 0);
+ GetTopic()->SetSelection(0);
+ }
+ }
+}
+
+void MyFrame::OnDisconnect(wxCommandEvent& WXUNUSED(event))
+{
+ Disconnect();
+}
+
+void MyFrame::Disconnect()
+{
+ delete m_client;
+ m_client = NULL;
+ Enable();
+}
+
+void MyFrame::OnStartAdvise(wxCommandEvent& WXUNUSED(event))
+{
+ m_client->GetConnection()->StartAdvise(_T("something"));
+}
+
+void MyFrame::OnStopAdvise(wxCommandEvent& WXUNUSED(event))
+{
+ m_client->GetConnection()->StopAdvise(_T("something"));
+}
+
+void MyFrame::OnExecute(wxCommandEvent& WXUNUSED(event))
+{
+ if (m_client->IsConnected())
+ {
+ wxString s = _T("Date");
+
+ m_client->GetConnection()->Execute((wxChar *)s.c_str());
+ m_client->GetConnection()->Execute((wxChar *)s.c_str(), (s.Length() + 1) * sizeof(wxChar));
+#if wxUSE_DDE_FOR_IPC
+ wxLogMessage(_T("DDE Execute can only be used to send text strings, not arbitrary data.\nThe type argument will be ignored, text truncated, converted to Unicode and null terminated."));
+#endif
+ char bytes[3];
+ bytes[0] = '1'; bytes[1] = '2'; bytes[2] = '3';
+ m_client->GetConnection()->Execute((wxChar *)bytes, 3, wxIPC_PRIVATE);
+ }
+}
+
+void MyFrame::OnPoke(wxCommandEvent& WXUNUSED(event))
+{
+ if (m_client->IsConnected())
+ {
+ wxString s = wxDateTime::Now().Format();
+ m_client->GetConnection()->Poke(_T("Date"), (wxChar *)s.c_str());
+ s = wxDateTime::Now().FormatTime() + _T(" ") + wxDateTime::Now().FormatDate();
+ m_client->GetConnection()->Poke(_T("Date"), (wxChar *)s.c_str(), (s.Length() + 1) * sizeof(wxChar));
+ char bytes[3];
+ bytes[0] = '1'; bytes[1] = '2'; bytes[2] = '3';
+ m_client->GetConnection()->Poke(_T("bytes[3]"), (wxChar *)bytes, 3, wxIPC_PRIVATE);
+ }
+}
+
+void MyFrame::OnRequest(wxCommandEvent& WXUNUSED(event))
+{
+ if (m_client->IsConnected())
+ {
+ int size;
+ m_client->GetConnection()->Request(_T("Date"));
+ m_client->GetConnection()->Request(_T("Date+len"), &size);
+ m_client->GetConnection()->Request(_T("bytes[3]"), &size, wxIPC_PRIVATE);
+ }
+}
+
+// ----------------------------------------------------------------------------
+// MyClient
+// ----------------------------------------------------------------------------
+MyClient::MyClient() : wxClient()
+{
+ m_connection = NULL;
+}
+
+bool MyClient::Connect(const wxString& sHost, const wxString& sService, const wxString& sTopic)
+{
+ // suppress the log messages from MakeConnection()
+ wxLogNull nolog;
+
+ m_connection = (MyConnection *)MakeConnection(sHost, sService, sTopic);
+ return m_connection != NULL;