Launching The Default Browser

From WxWiki
Jump to navigation Jump to search

Launching the Default Browser

With wxWidgets versions 2.6 and up you can use wxLaunchDefaultBrowser.

Versions below 2.6

Keywords: wxExecute browser url

Julian published this Code To View A HTML File on the mailinglists. Functionality like this is on the wishlist for a later version of wxWidgets. (Note: this does not work with KDE 3.2!)

There is also wxHyperlinksCtrl class from Angelo Mandato at

Using Mimetypes

I haven't tested this for html files, but wouldn't this simply work?

wxMimeTypesManager manager;
wxFileType * filetype = manager.GetFileTypeFromExtension("txt");
wxString command = filetype->GetOpenCommand("");

(add error handling yourself ;))

Windows and UNIX

The ClickableURL::OpenInBrowser() function at (Thanks to Vadim)


Semi-working Mac code: (Thanks to arkanes)

and also: Carbon Code To Open URLs On WxMac (Thanks to Aj Lavin)

You could also use the "open" command with wxExecute to open the default webbrowser for a file/url. Try this on the command-line (Applications/Utilities/Terminal)

% open ""

This will only work on OS X.