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 AboutDialog::OnHyperLinkClick(wxHyperlinkEvent &event) { if (event.GetEventObject() == theLicenseLink) { ViewTextDialog *dlg = //new ViewTextDialog(this, _T("NASA Open Source Agreement"), false, // wxDefaultPosition, wxSize(450, 300)); new ViewTextDialog(this, _T("Apache License, Version 2.0"), false, wxDefaultPosition, wxSize(400, 300)); wxString rootPath = FileManager::Instance()->GetRootPath().c_str(); wxString fileName = rootPath + "License.txt"; if (!GmatFileUtil::DoesFileExist(fileName.c_str())) fileName = "../License.txt"; wxTextCtrl *text = dlg->GetTextCtrl(); text->LoadFile(fileName); dlg->ShowModal(); } }