// headers
// ----------------------------------------------------------------------------
-#if defined(__GNUG__) && !defined(__APPLE__)
- #pragma implementation
- #pragma interface
-#endif
-
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#include "wx/txtstrm.h"
#include "wx/numdlg.h"
+#include "wx/textdlg.h"
#include "wx/ffile.h"
#include "wx/process.h"
void OnPOpen(wxCommandEvent& event);
void OnFileExec(wxCommandEvent& event);
+ void OnOpenURL(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
Exec_Shell,
Exec_POpen,
Exec_OpenFile,
+ Exec_OpenURL,
Exec_DDEExec,
Exec_DDERequest,
Exec_Redirect,
EVT_MENU(Exec_POpen, MyFrame::OnPOpen)
EVT_MENU(Exec_OpenFile, MyFrame::OnFileExec)
+ EVT_MENU(Exec_OpenURL, MyFrame::OnOpenURL)
#ifdef __WINDOWS__
EVT_MENU(Exec_DDEExec, MyFrame::OnDDEExec)
execMenu->AppendSeparator();
execMenu->Append(Exec_OpenFile, _T("Open &file...\tCtrl-F"),
_T("Launch the command to open this kind of files"));
+ execMenu->Append(Exec_OpenURL, _T("Open &URL...\tCtrl-U"),
+ _T("Launch the default browser with the given URL"));
#ifdef __WINDOWS__
execMenu->AppendSeparator();
execMenu->Append(Exec_DDEExec, _T("Execute command via &DDE...\tCtrl-D"));
return;
}
+ wxLogVerbose(_T("PID of the new process: %ld"), process->GetPid());
+
wxOutputStream *out = process->GetOutputStream();
if ( !out )
{
wxString filename;
#if wxUSE_FILEDLG
- filename = wxLoadFileSelector(wxEmptyString, wxEmptyString, s_filename);
-#endif // wxUSE_FILEDLG
+ filename = wxLoadFileSelector(_T("any file"), NULL, s_filename, this);
+#else // !wxUSE_FILEDLG
+ filename = wxGetTextFromUser(_T("Enter the file name"), _T("exec sample"),
+ s_filename, this);
+#endif // wxUSE_FILEDLG/!wxUSE_FILEDLG
if ( filename.empty() )
return;
DoAsyncExec(cmd);
}
+void MyFrame::OnOpenURL(wxCommandEvent& WXUNUSED(event))
+{
+ static wxString s_filename;
+
+ wxString filename = wxGetTextFromUser
+ (
+ _T("Enter the URL"),
+ _T("exec sample"),
+ s_filename,
+ this
+ );
+
+ if ( filename.empty() )
+ return;
+
+ s_filename = filename;
+
+ if ( !wxLaunchDefaultBrowser(s_filename) )
+ wxLogError(_T("Failed to open URL \"%s\""), s_filename.c_str());
+}
+
// ----------------------------------------------------------------------------
// DDE stuff
// ----------------------------------------------------------------------------