Morya

wxWidgets 在创建窗口之前处理命令行

文件在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;
}

posted on 2008-11-04 21:53 Morya 阅读(415) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


导航

<2008年11月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

统计

常用链接

留言簿(1)

随笔档案(21)

文章档案(1)

最新评论

评论排行榜