Hi!
It would be nice to have a function that can open a file in the associated
program.
html->browser,
doc->Ms WORD
PDF->Acrobat reader ect.
I have written a function for that, because you have to ask the
mime-manager for every opening. So I created a function that does that for
me. But it's not in wxw-style, maybe it can be a suggestion:
void wxDisplayFile(const wxString& FileName)
{
// Is the ile actually there?
if(!wxFileExists(FileName))
throw file_not_found(FileName);
// Retrieve open command using mime-types manager
wxFileName fn(FileName);
wxString ext = fn.GetExt();
boost::scoped_ptr<wxFileType>
ft(wxTheMimeTypesManager->GetFileTypeFromExtension(ext));
if(ft == NULL)
throw std::runtime_error(str(boost::format("Datei %s kann nicht geöffnet
werden.\n"
"Es konnte keine Standardanwendung für den Dateityp gefunden werden!") %
FileName).c_str());
wxString cmd = ft->GetOpenCommand(FileName);
if(cmd.Len())
wxExecute(cmd);
else
throw std::runtime_error(str(boost::format("Datei %s kann nicht geöffnet
werden.\n"
"Es konnte keine Standardanwendung für den Dateityp gefunden werden!") %
FileName).c_str());
}
Nobody/Anonymous
None
None
Public
|
Date: 2008-05-20 21:51
|
|
Date: 2008-02-27 07:59
|
|
Date: 2008-02-27 02:22
|
| Field | Old Value | Date | By |
|---|---|---|---|
| priority | 5 | 2008-02-27 02:22 | vadz |