Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command line arguments in wxWidgets

Is there a way I can read the command line arguments passed into a C++ wxWidgets application? If so, could you please provide an example of how to do so.

like image 333
jack Avatar asked Apr 12 '12 06:04

jack


1 Answers

In plain C++, there is argc and argv. When you are building a wxWidgets application, you can access these using wxApp::argc, wxApp::argv[] or wxAppConsole::argc, wxAppConsole::argv[]. Note that wxApp is derived from wxAppConsole, so either works depending on if you have a console app or GUI app. See wxAppConsole

IMPLEMENT_APP(MyApp)

bool MyApp::OnInit() {
// Access command line arguments with wxApp::argc, wxApp::argv[0], etc.
// ...
}

You may also be interested in wxCmdLineParser.

like image 178
JohnPS Avatar answered Sep 24 '22 07:09

JohnPS