Opening text files from the File Explorer in my app isn't working Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
qtSucks
In need of some credit
In need of some credit
Posts: 9
Joined: Fri Jan 22, 2021 6:32 pm

Opening text files from the File Explorer in my app isn't working

Post by qtSucks » Sat Jan 23, 2021 9:20 pm

I made a notepad app where one can open, modify and save files. It works perfectly. But when I open a .txt file from the File Explorer window, there opens just my app with empty wxTextCtrl.

I find this very natural: Of course Windows 10 cannot know that this app opens and saves txt files. So it just opens my app and no file. But my question is: How can I tell the File Explorer, that when the txt file is opened, run the OnOpen() method, for example?

User avatar
doublemax
Moderator
Moderator
Posts: 16019
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Opening text files from the File Explorer in my app isn't working

Post by doublemax » Sun Jan 24, 2021 12:07 am

If a file is opened with application (e.g. by dropping it on the exe), you will receive its path as command line argument, accessible through wxAppConsole::argc/argv
https://docs.wxwidgets.org/trunk/classw ... 31a5e8bfc5
Use the source, Luke!

qtSucks
In need of some credit
In need of some credit
Posts: 9
Joined: Fri Jan 22, 2021 6:32 pm

Re: Opening text files from the File Explorer in my app isn't working

Post by qtSucks » Sun Jan 24, 2021 1:12 pm

Thank you! If the number of arguments is not equal to 1, I open the file of the second argument. If it is equal to 1, I just start the app normally.

Post Reply