Open with

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
Moogamouth
In need of some credit
In need of some credit
Posts: 3
Joined: Sat Jan 23, 2021 8:56 pm

Open with

Post by Moogamouth »

Is there a way to control what happens when someone opens a file with my program with wxWidgets or any other C++ library?
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Open with

Post by doublemax »

In the case of "open with..." the same thing happens as if the user had dragged and dropped a file onto your executable: The xecutable will be started and the path of the dropped file will be passed as command line arguments, argc/argv.
http://crasseux.com/books/ctutorial/argc-and-argv.html

As the main() function is usually not exposed in wxWidgets, you can access argc/argv through wxAppConsole::argc/argv
https://docs.wxwidgets.org/trunk/classw ... 31a5e8bfc5
Use the source, Luke!
Moogamouth
In need of some credit
In need of some credit
Posts: 3
Joined: Sat Jan 23, 2021 8:56 pm

Re: Open with

Post by Moogamouth »

How would I obtain this file path you speak of? Also, please note, I don't need cross platform answers, but they would be nice. Also, if there is a way that isn't using wxwidgets, please tell me.
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Open with

Post by doublemax »

Moogamouth wrote: Sun Jan 24, 2021 5:21 am How would I obtain this file path you speak of? Also, please note, I don't need cross platform answers, but they would be nice. Also, if there is a way that isn't using wxwidgets, please tell me.
The first link i posted explains exactly what you have to do.
Use the source, Luke!
Moogamouth
In need of some credit
In need of some credit
Posts: 3
Joined: Sat Jan 23, 2021 8:56 pm

Re: Open with

Post by Moogamouth »

Sorry.
Post Reply