wxCmdLineParser

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
ruvindra
Knows some wx things
Knows some wx things
Posts: 34
Joined: Mon May 26, 2008 3:38 pm
Location: Colombo , Sri lanka
Contact:

wxCmdLineParser

Post by ruvindra » Mon May 26, 2008 3:53 pm

I am using the wxCmdLineParser to parse the command line options.

When I run the code I get the Error message as in the attached image

I have added the 's' switch as a switch to the code and used the running code available in the internet.

The code is

Application.h

Code: Select all

 static const wxCmdLineEntryDesc g_cmdLineDesc [] = {
        { wxCMD_LINE_SWITCH, "s", _("silent"), _("Minimize and Hides the GUI in System Tray"),wxCMD_LINE_VAL_NONE,wxCMD_LINE_PARAM_OPTIONAL },
		{ wxCMD_LINE_NONE, NULL, NULL, NULL, wxCMD_LINE_VAL_NONE, 0},
};
DECLARE_APP(Application)

Application.cpp

Code: Select all

 void Application::onInitCmdLine(wxCmdLineParser& parser)
{
	writeFile("onInitCmdLine entered");
	parser.DisableLongOptions();
	//parser.AddSwitch("s","silent","Minimize the app to System tray");
    parser.SetDesc (g_cmdLineDesc);
    // must refuse '/' as parameter starter or cannot use "/path" style paths
    parser.SetSwitchChars (wxT("-"));
	writeFile("onInitCmdLine exited");
}
 
bool Application::onCmdLineParsed(wxCmdLineParser& parser)
{
	writeFile("onCmdLineParsed entered");
	silent_mode = parser.Found(wxT("s"));
    if(silent_mode)writeFile("silent_mode is true");
	else writeFile("silent_mode is false");
    // to get at your unnamed parameters use
    wxArrayString files;
    for (int i = 0; i < parser.GetParamCount(); i++)
    {
            files.Add(parser.GetParam(i));
    }
 
    // and other command line parameters
 
    // then do what you need with them.
    writeFile("onCmdLineParsed exited");
    return true;
}

bool Application::OnInit()
{
	writeFile("Base class OnInit entered");
	if (!wxApp::OnInit())
        return false;
	writeFile("Base class OnInit exited");

 .....//Some my logic

}
The event methods are not fired when I run from my application. But the sample application downloaded, runs perfectly fine.


Could some one please help me to solve this problem? (I am running out of my dead line)

Thanks
Rangana
[/img]
Attachments
error.JPG
error.JPG (33.96 KiB) Viewed 1000 times
Range

benedicte
wxWorld Domination!
wxWorld Domination!
Posts: 1409
Joined: Wed Jan 19, 2005 3:44 pm
Location: Paris, France

Post by benedicte » Mon May 26, 2008 4:34 pm

I made a post about this some time ago (http://forums.wxwidgets.org/viewtopic.php?t=3882). Maybe you could have a look at it and compare with your code.

Post Reply