+
+// ============================================================================
+// MyPipeFrame implementation
+// ============================================================================
+
+MyPipeFrame::MyPipeFrame(wxFrame *parent,
+ const wxString& cmd,
+ wxProcess *process)
+ : wxFrame(parent, -1, cmd),
+ m_process(process),
+ // in a real program we'd check that the streams are !NULL here
+ m_in(*process->GetInputStream()),
+ m_out(*process->GetOutputStream())
+{
+ m_textIn = new wxTextCtrl(this, -1, _T(""),
+ wxDefaultPosition, wxDefaultSize,
+ wxTE_PROCESS_ENTER);
+ m_textOut = new wxTextCtrl(this, -1, _T(""));
+ m_textOut->SetEditable(FALSE);
+
+ wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL);
+ sizerTop->Add(m_textIn, 0, wxGROW | wxALL, 5);
+
+ wxSizer *sizerBtns = new wxBoxSizer(wxHORIZONTAL);
+ sizerBtns->Add(new wxButton(this, Exec_Btn_Send, _T("&Send")), 0,
+ wxALL, 10);
+ sizerBtns->Add(new wxButton(this, Exec_Btn_Get, _T("&Get")), 0,
+ wxALL, 10);
+
+ sizerTop->Add(sizerBtns, 0, wxCENTRE | wxALL, 5);
+ sizerTop->Add(m_textOut, 0, wxGROW | wxALL, 5);
+
+ SetSizer(sizerTop);
+ sizerTop->Fit(this);
+
+ Show();
+}
+
+void MyPipeFrame::DoGet()
+{
+ m_textOut->SetValue(m_in.ReadLine());
+}
+
+void MyPipeFrame::OnClose(wxCloseEvent& event)
+{
+ m_process->CloseOutput();
+
+ event.Skip();
+}
+