+ wxTextCtrl * const textLog = new wxTextCtrl
+ (
+ panel,
+ wxID_ANY,
+ "",
+ wxDefaultPosition, wxSize(500, 140),
+ wxTE_MULTILINE
+ );
+ sizerLog->Add(textLog, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
+
+ sizerMain->Add(sizerLog, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
+
+ panel->SetSizer(sizerMain);
+ sizerMain->SetSizeHints(panel);
+ SetClientSize(panel->GetSize());
+
+ GetServername()->SetSelection(0);
+ wxLogTextCtrl *logWindow = new wxLogTextCtrl(textLog);
+ delete wxLog::SetActiveTarget(logWindow);
+ wxLogMessage("Click on Start to start the server");
+ UpdateUI();
+}
+
+void MyFrame::UpdateUI()
+{
+ GetStart()->Enable(m_server == NULL);
+ GetServername()->Enable(m_server == NULL);
+ GetAdvise()->Enable(m_server && m_server->CanAdvise());
+ GetDisconnect()->Enable(m_server && m_server->IsConnected());
+}
+
+void MyFrame::OnClose(wxCloseEvent& event)
+{
+ wxDELETE(m_server);
+ event.Skip();
+}
+
+void MyFrame::OnStart(wxCommandEvent& WXUNUSED(event))
+{
+ // Create a new server
+ m_server = new MyServer;
+ wxString servername = GetServername()->GetStringSelection();
+ if (m_server->Create(servername))
+ {
+ wxLogMessage("Server %s started", servername);
+ #if wxUSE_DDE_FOR_IPC
+ wxLogMessage("Server uses DDE");
+ #else // !wxUSE_DDE_FOR_IPC
+ wxLogMessage("Server uses TCP");
+ #endif // wxUSE_DDE_FOR_IPC/!wxUSE_DDE_FOR_IPC
+ }
+ else
+ {
+ wxLogMessage("Server %s failed to start", servername);
+ wxDELETE(m_server);
+ }
+ UpdateUI();