文件在OnInit()函数中可以自定义处理命令行解析。
文件 $(wxWidgetsDIR)\src\common\appbase.cpp
class WXDLLIMPEXP_BASE wxAppConsole : public wxEvtHandler
{
public:
/*
.
.
.
*/
// Called before OnRun(), this is a good place to do initialization -- if
// anything fails, return false from here to prevent the program from
// continuing. The command line is normally parsed here, call the base
// class OnInit() to do it.
virtual bool OnInit();
};
否则,则可以在
bool TheApp::OnInit(){
if(!wxApp::OnInit()) return false;
// ..
// ..
}
可以在自己的OnInit()函数中自己处理命令行。
class TheApp : public wxApp{
public:
TheApp();
virtual bool OnInit();
virtual int OnRun();
virtual void OnCmdLineParsed();
};
TheApp::OnInit(){
cmdParser.SetCmdLine( argc, argv);
bool cont;
cont = false;
OnInitCmdLine( cmdParser );
switch ( int parseResult = cmdParser.Parse( false /* don't show usage */) ){
case -1:// show usage message
cont = false;
break;
case 0: // normal parsed
cont = OnCmdLineParsed( cmdParser);
break;
default: // parsed error
cont = false;// OnCmdLineError( cmdParser);
break;
}
if( !cont){
return false;
}