wxLaunchDefaultBrowser() now supports wxBROWSER_NEW_WINDOW flag (and it actually works correctly, too)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35669 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -5,6 +5,10 @@ wxWidgets Change Log - For more verbose changes, see the manual
|
|||||||
2.7.0
|
2.7.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
All:
|
||||||
|
|
||||||
|
- wxLaunchDefaultBrowser() now supports wxBROWSER_NEW_WINDOW flag
|
||||||
|
|
||||||
wxMSW:
|
wxMSW:
|
||||||
|
|
||||||
- wxFileDialog respects absence of wxCHANGE_DIR flag under NT (Brad Anderson)
|
- wxFileDialog respects absence of wxCHANGE_DIR flag under NT (Brad Anderson)
|
||||||
|
@@ -3048,16 +3048,19 @@ frame or dialog containing it, or {\tt NULL}.
|
|||||||
|
|
||||||
\membersection{::wxLaunchDefaultBrowser}\label{wxlaunchdefaultbrowser}
|
\membersection{::wxLaunchDefaultBrowser}\label{wxlaunchdefaultbrowser}
|
||||||
|
|
||||||
\func{bool}{wxLaunchDefaultBrowser}{\param{const wxString\& }{sUrl}}
|
\func{bool}{wxLaunchDefaultBrowser}{\param{const wxString\& }{url}, \param{int }{flags = $0$}}
|
||||||
|
|
||||||
Launches the user's default browser and tells it to open the location at {\tt sUrl}.
|
Open the \arg{url} in user's default browser. If \arg{flags} parameter contains
|
||||||
|
\texttt{wxBROWSER\_NEW\_WINDOW} flag, a new window is opened for the URL
|
||||||
|
(currently this is only supported under Windows).
|
||||||
|
|
||||||
Returns true if the application was successfully launched.
|
Returns \true if the application was successfully launched.
|
||||||
|
|
||||||
\wxheading{Include files}
|
\wxheading{Include files}
|
||||||
|
|
||||||
<wx/utils.h>
|
<wx/utils.h>
|
||||||
|
|
||||||
|
|
||||||
\membersection{::wxLoadUserResource}\label{wxloaduserresource}
|
\membersection{::wxLoadUserResource}\label{wxloaduserresource}
|
||||||
|
|
||||||
\func{wxString}{wxLoadUserResource}{\param{const wxString\& }{resourceName}, \param{const wxString\& }{resourceType=``TEXT"}}
|
\func{wxString}{wxLoadUserResource}{\param{const wxString\& }{resourceName}, \param{const wxString\& }{resourceType=``TEXT"}}
|
||||||
|
@@ -209,6 +209,13 @@ WXDLLIMPEXP_BASE long wxExecute(const wxString& command,
|
|||||||
wxArrayString& error,
|
wxArrayString& error,
|
||||||
int flags = 0);
|
int flags = 0);
|
||||||
|
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
// ask a DDE server to execute the DDE request with given parameters
|
||||||
|
WXDLLIMPEXP_BASE bool wxExecuteDDE(const wxString& ddeServer,
|
||||||
|
const wxString& ddeTopic,
|
||||||
|
const wxString& ddeCommand);
|
||||||
|
#endif // __WXMSW__
|
||||||
|
|
||||||
enum wxSignal
|
enum wxSignal
|
||||||
{
|
{
|
||||||
wxSIGNONE = 0, // verify if the process exists under Unix
|
wxSIGNONE = 0, // verify if the process exists under Unix
|
||||||
@@ -319,8 +326,15 @@ WXDLLIMPEXP_BASE bool wxHandleFatalExceptions(bool doit = true);
|
|||||||
#endif // wxUSE_ON_FATAL_EXCEPTION
|
#endif // wxUSE_ON_FATAL_EXCEPTION
|
||||||
|
|
||||||
#if wxABI_VERSION >= 20601
|
#if wxABI_VERSION >= 20601
|
||||||
|
|
||||||
|
// flags for wxLaunchDefaultBrowser
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
wxBROWSER_NEW_WINDOW = 1
|
||||||
|
};
|
||||||
|
|
||||||
// Launch url in the user's default internet browser
|
// Launch url in the user's default internet browser
|
||||||
WXDLLIMPEXP_BASE bool wxLaunchDefaultBrowser(const wxString& url);
|
WXDLLIMPEXP_BASE bool wxLaunchDefaultBrowser(const wxString& url, int flags = 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -520,14 +520,74 @@ long wxExecute(const wxString& command,
|
|||||||
// Launch default browser
|
// Launch default browser
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool wxLaunchDefaultBrowser(const wxString& urlOrig)
|
bool wxLaunchDefaultBrowser(const wxString& urlOrig, int flags)
|
||||||
{
|
{
|
||||||
|
wxUnusedVar(flags);
|
||||||
|
|
||||||
// set the scheme of url to http if it does not have one
|
// set the scheme of url to http if it does not have one
|
||||||
wxString url(urlOrig);
|
wxString url(urlOrig);
|
||||||
if ( !wxURI(url).HasScheme() )
|
if ( !wxURI(url).HasScheme() )
|
||||||
url.Prepend(wxT("http://"));
|
url.Prepend(wxT("http://"));
|
||||||
|
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW__)
|
||||||
|
if ( flags & wxBROWSER_NEW_WINDOW )
|
||||||
|
{
|
||||||
|
// ShellExecuteEx() opens the URL in an existing window by default so
|
||||||
|
// we can't use it if we need a new window
|
||||||
|
wxRegKey key(wxRegKey::HKCR, url.BeforeFirst(':') + _T("\\shell\\open"));
|
||||||
|
if ( key.Exists() )
|
||||||
|
{
|
||||||
|
wxRegKey keyDDE(key, wxT("DDEExec"));
|
||||||
|
if ( keyDDE.Exists() )
|
||||||
|
{
|
||||||
|
const wxString ddeTopic = wxRegKey(keyDDE, wxT("topic"));
|
||||||
|
|
||||||
|
// we only know the syntax of WWW_OpenURL DDE request for IE,
|
||||||
|
// optimistically assume that all other browsers are compatible
|
||||||
|
// with it
|
||||||
|
wxString ddeCmd;
|
||||||
|
bool ok = ddeTopic == wxT("WWW_OpenURL");
|
||||||
|
if ( ok )
|
||||||
|
{
|
||||||
|
ddeCmd = keyDDE;
|
||||||
|
ok = !ddeCmd.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ok )
|
||||||
|
{
|
||||||
|
// for WWW_OpenURL, the index of the window to open the URL
|
||||||
|
// in is -1 (meaning "current") by default, replace it with
|
||||||
|
// 0 which means "new" (see KB article 160957)
|
||||||
|
ok = ddeCmd.Replace(wxT("-1"), wxT("0"),
|
||||||
|
false /* only first occurence */) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ok )
|
||||||
|
{
|
||||||
|
// and also replace the parameters: the topic should
|
||||||
|
// contain a placeholder for the URL
|
||||||
|
ok = ddeCmd.Replace(wxT("%1"), url, false) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ok )
|
||||||
|
{
|
||||||
|
// try to send it the DDE request now but ignore the errors
|
||||||
|
wxLogNull noLog;
|
||||||
|
|
||||||
|
const wxString ddeServer = wxRegKey(keyDDE, wxT("application"));
|
||||||
|
if ( wxExecuteDDE(ddeServer, ddeTopic, ddeCmd) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// this is not necessarily an error: maybe browser is
|
||||||
|
// simply not running, but no matter, in any case we're
|
||||||
|
// going to launch it using ShellExecuteEx() below now and
|
||||||
|
// we shouldn't try to open a new window if we open a new
|
||||||
|
// browser anyhow
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WinStruct<SHELLEXECUTEINFO> sei;
|
WinStruct<SHELLEXECUTEINFO> sei;
|
||||||
sei.lpFile = url.c_str();
|
sei.lpFile = url.c_str();
|
||||||
sei.lpVerb = _T("open");
|
sei.lpVerb = _T("open");
|
||||||
|
@@ -483,16 +483,16 @@ size_t wxPipeOutputStream::OnSysWrite(const void *buffer, size_t len)
|
|||||||
#if wxUSE_IPC
|
#if wxUSE_IPC
|
||||||
|
|
||||||
// connect to the given server via DDE and ask it to execute the command
|
// connect to the given server via DDE and ask it to execute the command
|
||||||
static bool wxExecuteDDE(const wxString& ddeServer,
|
bool
|
||||||
|
wxExecuteDDE(const wxString& ddeServer,
|
||||||
const wxString& ddeTopic,
|
const wxString& ddeTopic,
|
||||||
const wxString& ddeCommand)
|
const wxString& ddeCommand)
|
||||||
{
|
{
|
||||||
bool ok wxDUMMY_INITIALIZE(false);
|
bool ok wxDUMMY_INITIALIZE(false);
|
||||||
|
|
||||||
wxDDEClient client;
|
wxDDEClient client;
|
||||||
wxConnectionBase *conn = client.MakeConnection(wxEmptyString,
|
wxConnectionBase *
|
||||||
ddeServer,
|
conn = client.MakeConnection(wxEmptyString, ddeServer, ddeTopic);
|
||||||
ddeTopic);
|
|
||||||
if ( !conn )
|
if ( !conn )
|
||||||
{
|
{
|
||||||
ok = false;
|
ok = false;
|
||||||
|
Reference in New Issue
Block a user