void TrackPropDlg::OnHyperLinkClick( wxHyperlinkEvent &event ) { if( m_toggleBtnEdit->GetValue() ) { m_pEditedLink = (wxHyperlinkCtrl*) event.GetEventObject(); OnEditLink( event ); event.Skip( false ); return; } // Windows has trouble handling local file URLs with embedded anchor points, e.g file://testfile.html#point1 // The trouble is with the wxLaunchDefaultBrowser with verb "open" // Workaround is to probe the registry to get the default browser, and open directly // // But, we will do this only if the URL contains the anchor point charater '#' // What a hack...... #ifdef __WXMSW__ wxString cc = event.GetURL(); if( cc.Find( _T("#") ) != wxNOT_FOUND ) { wxRegKey RegKey( wxString( _T("HKEY_CLASSES_ROOT\\HTTP\\shell\\open\\command") ) ); if( RegKey.Exists() ) { wxString command_line; RegKey.QueryValue( wxString( _T("") ), command_line ); // Remove " command_line.Replace( wxString( _T("\"") ), wxString( _T("") ) ); // Strip arguments int l = command_line.Find( _T(".exe") ); if( wxNOT_FOUND == l ) l = command_line.Find( _T(".EXE") ); if( wxNOT_FOUND != l ) { wxString cl = command_line.Mid( 0, l + 4 ); cl += _T(" "); cc.Prepend( _T("\"") ); cc.Append( _T("\"") ); cl += cc; wxExecute( cl ); // Async, so Fire and Forget... } } } else event.Skip(); #else wxString url = event.GetURL(); url.Replace(_T(" "), _T("%20") ); ::wxLaunchDefaultBrowser(url); // event.Skip(); #endif }
void CAbout::OnVisitSiteClicked(wxHyperlinkEvent& event) { // Do nothing to prevent double open, because GTK control opens URL by itself, // otherwise default handler will call xdg-open to open URL #ifndef __WXGTK__ // skip this hook and leave default processing for non-GTK builds event.Skip(); #else wxUnusedVar(event); #endif }