1. small fix in wxDirDialog: SHBrowseForFolder() doesn't like '/'s

2. streamlined DDE code (better error handling, range checking)
3. hack in wxExecute to allow launching DDE servers
4. changed wxTreeCtrl::m_filename scope from private to protected
5. corrected creating wxBitmaps from XBMs
6. wxListCtrl no longer sends bogus ACTIVATED events


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5488 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-01-18 01:22:56 +00:00
parent 052e12db71
commit 5bd3a2da95
11 changed files with 944 additions and 583 deletions

View File

@@ -74,6 +74,8 @@
#endif
#include <stdarg.h>
#include "wx/dde.h" // for WX_DDE hack in wxExecute
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
@@ -177,9 +179,78 @@ LRESULT APIENTRY _EXPORT wxExecuteWindowCbk(HWND hWnd, UINT message,
}
#endif
long wxExecute(const wxString& command, bool sync, wxProcess *handler)
long wxExecute(const wxString& cmd, bool sync, wxProcess *handler)
{
wxCHECK_MSG( !!command, 0, wxT("empty command in wxExecute") );
wxCHECK_MSG( !!cmd, 0, wxT("empty command in wxExecute") );
// DDE hack: this is really not pretty, but we need to allow this for
// transparent handling of DDE servers in wxMimeTypesManager. Usually it
// returns the command which should be run to view/open/... a file of the
// given type. Sometimes, however, this command just launches the server
// and an additional DDE request must be made to really open the file. To
// keep all this well hidden from the application, we allow a special form
// of command: WX_DDE:<command>:DDE_SERVER:DDE_TOPIC:DDE_COMMAND in which
// case we execute just <command> and process the rest below
wxString command, ddeServer, ddeTopic, ddeCommand;
static const size_t lenDdePrefix = 7; // strlen("WX_DDE:")
if ( cmd.Left(lenDdePrefix) == _T("WX_DDE#") )
{
const wxChar *p = cmd.c_str() + 7;
while ( *p && *p != _T('#') )
{
command += *p++;
}
if ( *p )
{
// skip '#'
p++;
}
else
{
wxFAIL_MSG(_T("invalid WX_DDE command in wxExecute"));
}
while ( *p && *p != _T('#') )
{
ddeServer += *p++;
}
if ( *p )
{
// skip '#'
p++;
}
else
{
wxFAIL_MSG(_T("invalid WX_DDE command in wxExecute"));
}
while ( *p && *p != _T('#') )
{
ddeTopic += *p++;
}
if ( *p )
{
// skip '#'
p++;
}
else
{
wxFAIL_MSG(_T("invalid WX_DDE command in wxExecute"));
}
while ( *p )
{
ddeCommand += *p++;
}
}
else
{
// no DDE
command = cmd;
}
#if defined(__WIN32__) && !defined(__TWIN32__)
// the old code is disabled because we really need a process handle
@@ -237,6 +308,7 @@ long wxExecute(const wxString& command, bool sync, wxProcess *handler)
return result;
#else // 1
// create the process
STARTUPINFO si;
wxZeroMemory(si);
@@ -338,6 +410,20 @@ long wxExecute(const wxString& command, bool sync, wxProcess *handler)
return pi.dwProcessId;
}
// second part of DDE hack: now establish the DDE conversation with the
// just launched process
if ( !!ddeServer )
{
wxDDEClient client;
wxConnectionBase *conn = client.MakeConnection(_T(""),
ddeServer,
ddeTopic);
if ( !conn || !conn->Execute(ddeCommand) )
{
wxLogError(_("Couldn't launch DDE server '%s'."), command.c_str());
}
}
if ( !sync )
{
// clean up will be done when the process terminates