// main frame
bool MyApp::OnInit()
{
+ if ( !wxApp::OnInit() )
+ return false;
+
// Create the main frame window
m_frame = new MyFrame(NULL, _T("Client"));
m_frame->Show(true);
GetHostname()->Enable(m_client == NULL);
GetTopic()->Enable(m_client == NULL);
- const bool isConnected = m_client->IsConnected();
+ const bool isConnected = (m_client != NULL && m_client->IsConnected());
GetDisconnect()->Enable(m_client != NULL && isConnected);
GetStartAdvise()->Enable(m_client != NULL && isConnected);
GetStopAdvise()->Enable(m_client != NULL && isConnected);
delete m_client;
m_client = NULL;
}
- Enable();
+ EnableControls();
}
void MyFrame::OnServername( wxCommandEvent& WXUNUSED(event) )
{
delete m_client;
m_client = NULL;
- Enable();
+ EnableControls();
}
void MyFrame::OnStartAdvise(wxCommandEvent& WXUNUSED(event))
{
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));
+ m_client->GetConnection()->Execute((const wxChar *)s.c_str());
+ m_client->GetConnection()->Execute((const 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
if (m_client->IsConnected())
{
wxString s = wxDateTime::Now().Format();
- m_client->GetConnection()->Poke(_T("Date"), (wxChar *)s.c_str());
+ m_client->GetConnection()->Poke(_T("Date"), (const 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));
+ m_client->GetConnection()->Poke(_T("Date"), (const 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);
m_connection->Disconnect();
delete m_connection;
m_connection = NULL;
- wxGetApp().GetFrame()->Enable();
+ wxGetApp().GetFrame()->EnableControls();
wxLogMessage(_T("Client disconnected from server"));
}
}
// ----------------------------------------------------------------------------
void MyConnection::Log(const wxString& command, const wxString& topic,
- const wxString& item, wxChar *data, int size, wxIPCFormat format)
+ const wxString& item, const wxChar *data, int size, wxIPCFormat format)
{
wxString s;
if (topic.IsEmpty() && item.IsEmpty())
return data;
}
-bool MyConnection::Poke(const wxString& item, wxChar *data, int size, wxIPCFormat format)
+bool MyConnection::Poke(const wxString& item, const wxChar *data, int size, wxIPCFormat format)
{
Log(_T("Poke"), wxEmptyString, item, data, size, format);
return wxConnection::Poke(item, data, size, format);