I am using wxMSW and wxGTK 2.8.11
In my old Windows programs I sometimes do this to open a file with the
program the user has associated with the file type
ShellExecute(NULL,"open",filepath, NULL, NULL, SW_SHOWNORMAL);
Is there a way to do the same in wxWidgets, that would work for wxMSW and
wxGTK?
On Windows I got this to work, however it also gave me a terminal window I
didn't want
::wxShell(filepath);
The above didn't work on Linux.
Instead I tried,
::wxExecute(filepath);
with much the same result
This worked for text files
::wxExecute(wxT("notepad ") + filepath); // Windows
::wxExecute(wxT("kate ") + filepath); // Linux
... but obviously the solution isn't common to Windows & Linux and it isn't
respecting the users choice of editor. Plus it doesn't work for other file
types.
Is there some way to open a file using the program defined by the file type
association in the OS? perhaps. something along the lines of
::wxExecute(filepath,wxEXEC_OPEN);
..to be a portable way of achieving the same as the ShellExecute example
above?
--
Carsten A. Arnholm
http://arnholm.org/
N59.7758 E10.4576
I can see now that the exec sample has something that appears to be what I
am looking for (OnFileExec function).
CAA> I am using wxMSW and wxGTK 2.8.11
You're out of luck, wxLaunchDefaultApplication() is in 2.9 only. In 2.8
you'll need to use wxMimeTypesManager manually, as the exec sample does (as
you already discovered).
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
CAA> I am using wxMSW and wxGTK 2.8.11
VZ> You're out of luck, wxLaunchDefaultApplication() is in 2.9 only. In 2.8
VZ> you'll need to use wxMimeTypesManager manually, as the exec sample does
(as
VZ> you already discovered).
VZ>
VZ> Regards,
VZ> VZ
Ok, many thanks, then I have the information requested. Nice to know this
will be even better in 2.9.
Again, thanks for the quick reply.
Carsten Arnholm