// headers
// ----------------------------------------------------------------------------
-#if defined(__GNUG__) && !defined(__APPLE__)
- #pragma implementation "exec.cpp"
- #pragma interface "exec.cpp"
-#endif
-
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#endif
// create a menu bar
- wxMenu *menuFile = new wxMenu(_T(""), wxMENU_TEAROFF);
+ wxMenu *menuFile = new wxMenu(wxEmptyString, wxMENU_TEAROFF);
menuFile->Append(Exec_Kill, _T("&Kill process...\tCtrl-K"),
_T("Kill a process by PID"));
menuFile->AppendSeparator();
execMenu->Append(Exec_DDERequest, _T("Send DDE &request...\tCtrl-R"));
#endif
- wxMenu *helpMenu = new wxMenu(_T(""), wxMENU_TEAROFF);
+ wxMenu *helpMenu = new wxMenu(wxEmptyString, wxMENU_TEAROFF);
helpMenu->Append(Exec_About, _T("&About...\tF1"), _T("Show about dialog"));
// now append the freshly created menu to the menu bar...
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
- wxMessageBox(_T("Exec wxWidgets Sample\n© 2000-2002 Vadim Zeitlin"),
+ wxMessageBox(_T("Exec wxWidgets Sample\n(c) 2000-2002 Vadim Zeitlin"),
_T("About Exec"), wxOK | wxICON_INFORMATION, this);
}
return;
}
+ wxLogVerbose(_T("PID of the new process: %ld"), process->GetPid());
+
wxOutputStream *out = process->GetOutputStream();
if ( !out )
{
{
static wxString s_filename;
- wxString filename = wxLoadFileSelector(_T(""), _T(""), s_filename);
- if ( !filename )
+ wxString filename;
+
+#if wxUSE_FILEDLG
+ filename = wxLoadFileSelector(wxEmptyString, wxEmptyString, s_filename);
+#endif // wxUSE_FILEDLG
+
+ if ( filename.empty() )
return;
s_filename = filename;
wxString cmd;
bool ok = ft->GetOpenCommand(&cmd,
- wxFileType::MessageParameters(filename, _T("")));
+ wxFileType::MessageParameters(filename));
delete ft;
if ( !ok )
{
return;
wxDDEClient client;
- wxConnectionBase *conn = client.MakeConnection(_T(""), m_server, m_topic);
+ wxConnectionBase *conn = client.MakeConnection(wxEmptyString, m_server, m_topic);
if ( !conn )
{
wxLogError(_T("Failed to connect to the DDE server '%s'."),
return;
wxDDEClient client;
- wxConnectionBase *conn = client.MakeConnection(_T(""), m_server, m_topic);
+ wxConnectionBase *conn = client.MakeConnection(wxEmptyString, m_server, m_topic);
if ( !conn )
{
wxLogError(_T("Failed to connect to the DDE server '%s'."),
bool MyPipedProcess2::HasInput()
{
- if ( !!m_input )
+ if ( !m_input.empty() )
{
wxTextOutputStream os(*GetOutputStream());
os.WriteString(m_input);
: wxFrame(parent, wxID_ANY, cmd),
m_process(process),
// in a real program we'd check that the streams are !NULL here
+ m_out(*process->GetOutputStream()),
m_in(*process->GetInputStream()),
- m_err(*process->GetErrorStream()),
- m_out(*process->GetOutputStream())
+ m_err(*process->GetErrorStream())
{
m_process->SetNextHandler(this);
wxPanel *panel = new wxPanel(this, wxID_ANY);
- m_textOut = new wxTextCtrl(panel, wxID_ANY, _T(""),
+ m_textOut = new wxTextCtrl(panel, wxID_ANY, wxEmptyString,
wxDefaultPosition, wxDefaultSize,
wxTE_PROCESS_ENTER);
- m_textIn = new wxTextCtrl(panel, wxID_ANY, _T(""),
+ m_textIn = new wxTextCtrl(panel, wxID_ANY, wxEmptyString,
wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE | wxTE_RICH);
m_textIn->SetEditable(false);
- m_textErr = new wxTextCtrl(panel, wxID_ANY, _T(""),
+ m_textErr = new wxTextCtrl(panel, wxID_ANY, wxEmptyString,
wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE | wxTE_RICH);
m_textErr->SetEditable(false);
void MyPipeFrame::OnBtnSendFile(wxCommandEvent& WXUNUSED(event))
{
+#if wxUSE_FILEDLG
wxFileDialog filedlg(this, _T("Select file to send"));
if ( filedlg.ShowModal() != wxID_OK )
return;
while ( len )
{
const size_t CHUNK_SIZE = 4096;
- size_t lenChunk = len > CHUNK_SIZE ? CHUNK_SIZE : len;
+ m_out.Write(pc, len > CHUNK_SIZE ? CHUNK_SIZE : len);
- m_out.Write(pc, lenChunk);
+ // note that not all data could have been written as we don't block on
+ // the write end of the pipe
+ const size_t lenChunk = m_out.LastWrite();
pc += lenChunk;
len -= lenChunk;
DoGet();
}
+#endif // wxUSE_FILEDLG
}
void MyPipeFrame::DoGet()