+void MyFrame::OnFileExec(wxCommandEvent& event)
+{
+ static wxString s_filename;
+
+ wxString filename = wxLoadFileSelector(_T("file"), _T(""), s_filename);
+ if ( !filename )
+ return;
+
+ s_filename = filename;
+
+ wxString ext = filename.AfterFirst(_T('.'));
+ wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(ext);
+ if ( !ft )
+ {
+ wxLogError(_T("Impossible to determine the file type for extension '%s'"),
+ ext.c_str());
+ return;
+ }
+
+ wxString cmd;
+ bool ok = ft->GetOpenCommand(&cmd,
+ wxFileType::MessageParameters(filename, _T("")));
+ delete ft;
+ if ( !ok )
+ {
+ wxLogError(_T("Impossible to find out how to open files of extension '%s'"),
+ ext.c_str());
+ return;
+ }
+
+ DoAsyncExec(cmd);
+}
+
+void MyFrame::OnDDEExec(wxCommandEvent& WXUNUSED(event))
+{
+#ifdef __WINDOWS__
+ wxString server = wxGetTextFromUser(_T("Server to connect to:"),
+ DIALOG_TITLE, _T("IExplore"));
+ if ( !server )
+ return;
+
+ wxString topic = wxGetTextFromUser(_T("DDE topic:"),
+ DIALOG_TITLE, _T("WWW_OpenURL"));
+ if ( !topic )
+ return;
+
+ wxString cmd = wxGetTextFromUser(_T("DDE command:"),
+ DIALOG_TITLE,
+ _T("\"file:F:\\wxWindows\\samples\\"
+ "image\\horse.gif\",,-1,,,,,"));
+ if ( !cmd )
+ return;
+
+ wxDDEClient client;
+ wxConnectionBase *conn = client.MakeConnection("", server, topic);
+ if ( !conn )
+ {
+ wxLogError(_T("Failed to connect to the DDE server '%s'."),
+ server.c_str());
+ }
+ else
+ {
+ if ( !conn->Execute(cmd) )
+ {
+ wxLogError(_T("Failed to execute command '%s' via DDE."),
+ cmd.c_str());
+ }
+ else
+ {
+ wxLogStatus(_T("Successfully executed DDE command"));
+ }
+ }
+#endif // __WINDOWS__
+}
+
+// input polling
+void MyFrame::OnIdle(wxIdleEvent& event)
+{
+ size_t count = m_running.GetCount();
+ for ( size_t n = 0; n < count; n++ )
+ {
+ if ( m_running[n]->HasInput() )
+ {
+ event.RequestMore();
+ }
+ }
+}
+
+void MyFrame::OnProcessTerminated(MyPipedProcess *process)
+{
+ m_running.Remove(process);
+}
+
+
+void MyFrame::ShowOutput(const wxString& cmd,
+ const wxArrayString& output,
+ const wxString& title)
+{
+ size_t count = output.GetCount();
+ if ( !count )
+ return;
+
+ m_lbox->Append(wxString::Format(_T("--- %s of '%s' ---"),
+ title.c_str(), cmd.c_str()));
+
+ for ( size_t n = 0; n < count; n++ )
+ {
+ m_lbox->Append(output[n]);
+ }
+
+ m_lbox->Append(_T("--- End of output ---"));
+}
+