fixed wxExecute + DDE bug (merged from 2.2)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10084 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
		@@ -93,8 +93,6 @@ public:
 | 
			
		||||
 | 
			
		||||
    void OnFileExec(wxCommandEvent& event);
 | 
			
		||||
 | 
			
		||||
    void OnDDEExec(wxCommandEvent& event);
 | 
			
		||||
 | 
			
		||||
    void OnAbout(wxCommandEvent& event);
 | 
			
		||||
 | 
			
		||||
    // polling output of async processes
 | 
			
		||||
@@ -111,8 +109,21 @@ private:
 | 
			
		||||
 | 
			
		||||
    void DoAsyncExec(const wxString& cmd);
 | 
			
		||||
 | 
			
		||||
    // last command we executed
 | 
			
		||||
    wxString m_cmdLast;
 | 
			
		||||
 | 
			
		||||
#ifdef __WINDOWS__
 | 
			
		||||
    void OnDDEExec(wxCommandEvent& event);
 | 
			
		||||
    void OnDDERequest(wxCommandEvent& event);
 | 
			
		||||
 | 
			
		||||
    bool GetDDEServer();
 | 
			
		||||
 | 
			
		||||
    // last params of a DDE transaction
 | 
			
		||||
    wxString m_server,
 | 
			
		||||
             m_topic,
 | 
			
		||||
             m_cmdDde;
 | 
			
		||||
#endif // __WINDOWS__
 | 
			
		||||
 | 
			
		||||
    wxListBox *m_lbox;
 | 
			
		||||
 | 
			
		||||
    MyProcessesArray m_running;
 | 
			
		||||
@@ -187,6 +198,7 @@ enum
 | 
			
		||||
    Exec_Shell,
 | 
			
		||||
    Exec_OpenFile,
 | 
			
		||||
    Exec_DDEExec,
 | 
			
		||||
    Exec_DDERequest,
 | 
			
		||||
    Exec_Redirect,
 | 
			
		||||
    Exec_Pipe,
 | 
			
		||||
    Exec_About = 300
 | 
			
		||||
@@ -214,6 +226,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
 | 
			
		||||
    EVT_MENU(Exec_OpenFile, MyFrame::OnFileExec)
 | 
			
		||||
 | 
			
		||||
    EVT_MENU(Exec_DDEExec, MyFrame::OnDDEExec)
 | 
			
		||||
    EVT_MENU(Exec_DDERequest, MyFrame::OnDDERequest)
 | 
			
		||||
 | 
			
		||||
    EVT_MENU(Exec_About, MyFrame::OnAbout)
 | 
			
		||||
 | 
			
		||||
@@ -292,6 +305,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
 | 
			
		||||
#ifdef __WINDOWS__
 | 
			
		||||
    execMenu->AppendSeparator();
 | 
			
		||||
    execMenu->Append(Exec_DDEExec, _T("Execute command via &DDE...\tCtrl-D"));
 | 
			
		||||
    execMenu->Append(Exec_DDERequest, _T("Send DDE &request...\tCtrl-R"));
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    wxMenu *helpMenu = new wxMenu(_T(""), wxMENU_TEAROFF);
 | 
			
		||||
@@ -529,48 +543,86 @@ void MyFrame::OnFileExec(wxCommandEvent& event)
 | 
			
		||||
    DoAsyncExec(cmd);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef __WINDOWS__
 | 
			
		||||
 | 
			
		||||
bool MyFrame::GetDDEServer()
 | 
			
		||||
{
 | 
			
		||||
    wxString server = wxGetTextFromUser(_T("Server to connect to:"),
 | 
			
		||||
                                        DIALOG_TITLE, m_server);
 | 
			
		||||
    if ( !server )
 | 
			
		||||
        return FALSE;
 | 
			
		||||
 | 
			
		||||
    m_server = server;
 | 
			
		||||
 | 
			
		||||
    wxString topic = wxGetTextFromUser(_T("DDE topic:"), DIALOG_TITLE, m_topic);
 | 
			
		||||
    if ( !topic )
 | 
			
		||||
        return FALSE;
 | 
			
		||||
 | 
			
		||||
    m_topic = topic;
 | 
			
		||||
 | 
			
		||||
    wxString cmd = wxGetTextFromUser(_T("DDE command:"), DIALOG_TITLE, m_cmdDde);
 | 
			
		||||
    if ( !cmd )
 | 
			
		||||
        return FALSE;
 | 
			
		||||
 | 
			
		||||
    m_cmdDde = cmd;
 | 
			
		||||
 | 
			
		||||
    return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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 )
 | 
			
		||||
    if ( !GetDDEServer() )
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    wxDDEClient client;
 | 
			
		||||
    wxConnectionBase *conn = client.MakeConnection("", server, topic);
 | 
			
		||||
    wxConnectionBase *conn = client.MakeConnection("", m_server, m_topic);
 | 
			
		||||
    if ( !conn )
 | 
			
		||||
    {
 | 
			
		||||
        wxLogError(_T("Failed to connect to the DDE server '%s'."),
 | 
			
		||||
                   server.c_str());
 | 
			
		||||
                   m_server.c_str());
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        if ( !conn->Execute(cmd) )
 | 
			
		||||
        if ( !conn->Execute(m_cmdDde) )
 | 
			
		||||
        {
 | 
			
		||||
            wxLogError(_T("Failed to execute command '%s' via DDE."),
 | 
			
		||||
                       cmd.c_str());
 | 
			
		||||
                       m_cmdDde.c_str());
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            wxLogStatus(_T("Successfully executed DDE command"));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
#endif // __WINDOWS__
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MyFrame::OnDDERequest(wxCommandEvent& WXUNUSED(event))
 | 
			
		||||
{
 | 
			
		||||
    if ( !GetDDEServer() )
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    wxDDEClient client;
 | 
			
		||||
    wxConnectionBase *conn = client.MakeConnection("", m_server, m_topic);
 | 
			
		||||
    if ( !conn )
 | 
			
		||||
    {
 | 
			
		||||
        wxLogError(_T("Failed to connect to the DDE server '%s'."),
 | 
			
		||||
                   m_server.c_str());
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        if ( !conn->Request(m_cmdDde) )
 | 
			
		||||
        {
 | 
			
		||||
            wxLogError(_T("Failed to  send request '%s' via DDE."),
 | 
			
		||||
                       m_cmdDde.c_str());
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            wxLogStatus(_T("Successfully sent DDE request."));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif // __WINDOWS__
 | 
			
		||||
 | 
			
		||||
// input polling
 | 
			
		||||
void MyFrame::OnIdle(wxIdleEvent& event)
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user