#include "wx/app.h"
#include "wx/frame.h"
#include "wx/utils.h"
+ #include "wx/menu.h"
+ #include "wx/msgdlg.h"
+ #include "wx/textdlg.h"
#endif
#include "wx/process.h"
+#ifdef __WINDOWS__
+ #include "wx/dde.h"
+#endif // __WINDOWS__
+
// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------
void OnSyncExec(wxCommandEvent& event);
void OnAsyncExec(wxCommandEvent& event);
void OnShell(wxCommandEvent& event);
+ void OnDDEExec(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
Exec_SyncExec = 200,
Exec_AsyncExec,
Exec_Shell,
+ Exec_DDEExec,
Exec_About = 300
};
+static const wxChar *DIALOG_TITLE = _T("Exec sample");
+
// ----------------------------------------------------------------------------
// event tables and other macros for wxWindows
// ----------------------------------------------------------------------------
EVT_MENU(Exec_SyncExec, MyFrame::OnSyncExec)
EVT_MENU(Exec_AsyncExec, MyFrame::OnAsyncExec)
EVT_MENU(Exec_Shell, MyFrame::OnShell)
+ EVT_MENU(Exec_DDEExec, MyFrame::OnDDEExec)
EVT_MENU(Exec_About, MyFrame::OnAbout)
END_EVENT_TABLE()
#endif
// set the frame icon
+#ifndef __WXGTK__
SetIcon(wxICON(mondrian));
+#endif
// create a menu bar
wxMenu *menuFile = new wxMenu(_T(""), wxMENU_TEAROFF);
execMenu->Append(Exec_Shell, _T("Execute &shell command...\tCtrl-S"),
_T("Launch a shell and execute a command in it"));
+#ifdef __WINDOWS__
+ execMenu->AppendSeparator();
+ execMenu->Append(Exec_DDEExec, _T("Execute command via &DDE...\tCtrl-D"));
+#endif
+
wxMenu *helpMenu = new wxMenu(_T(""), wxMENU_TEAROFF);
helpMenu->Append(Exec_About, _T("&About...\tF1"), _T("Show about dialog"));
#if wxUSE_STATUSBAR
// create a status bar just for fun (by default with 1 pane only)
- CreateStatusBar(2);
+ CreateStatusBar();
SetStatusText(_T("Welcome to wxWindows!"));
#endif // wxUSE_STATUSBAR
}
void MyFrame::OnSyncExec(wxCommandEvent& WXUNUSED(event))
{
wxString cmd = wxGetTextFromUser(_T("Enter the command: "),
- _T("Exec sample"),
+ DIALOG_TITLE,
m_cmdLast);
if ( !cmd )
void MyFrame::OnAsyncExec(wxCommandEvent& WXUNUSED(event))
{
wxString cmd = wxGetTextFromUser(_T("Enter the command: "),
- _T("Exec sample"),
+ DIALOG_TITLE,
m_cmdLast);
if ( !cmd )
void MyFrame::OnShell(wxCommandEvent& WXUNUSED(event))
{
wxString cmd = wxGetTextFromUser(_T("Enter the command: "),
- _T("Exec sample"),
+ DIALOG_TITLE,
m_cmdLast);
if ( !cmd )
m_cmdLast = 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__
+}
+
// ----------------------------------------------------------------------------
// MyProcess
// ----------------------------------------------------------------------------