Re: Program Return Codes in wxWidgets

342 views
Skip to first unread message

Bradley Arsenault

unread,
Jul 5, 2005, 1:12:45 AM7/5/05
to wx-u...@lists.wxwidgets.org
Ok, i have tried that, it does not seem to like me. the wxApp::OnRun
function isn't even being called.

On 6/29/05, scott <sco...@yahoo.com> wrote:
> Bradley Arsenault wrote:
> > I'm having trouble with program return codes in wxWidgets. It seems
> > utterly impossible for one to change the return code of a program, I
> > cant find any function anywhere. The return code should be the one
> > returned from main() or given to exit(), but it seems the only
> > exit/return code wxWidgets will ever pass out is 255, which is a
> > standard "Something Went Wrong" for applications on Unix. Im trying to
> > build a testing suite for my gui program to be integrated with `make
> > check`, but it still is a failing.
> >
> > Ive heard that what OnExit() returns is ignored, and a possible thing
> > to do with it is to be the programs exit/return code. How do i get
> > around this delima?
>
> What I do under Windows is override the wxApp::OnRun function and return
> the desired exit code from there. Similar to
>
> int MyApp::OnRun()
> {
> // run application
> wxApp::OnRun();
>
> // return my exit code
> return exitCode;
> }
>
> I think the return code from OnExit is ignored so the last thing I do
> after any application-specific cleanup is simply call the base class
> function, wxApp::OnExit(), from my application OnExit function. Like this
>
> int MyApp::OnExit()
> {
> // do my cleanup here
>
> // exit application
> return wxApp::OnExit();
> }
>
> HTH,
>
> Scott
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-u...@lists.wxwidgets.org
> For additional commands, e-mail: wx-use...@lists.wxwidgets.org
>
>

scott

unread,
Jul 5, 2005, 9:56:39 AM7/5/05
to wx-u...@lists.wxwindows.org
Bradley Arsenault wrote:
> Ok, i have tried that, it does not seem to like me. the wxApp::OnRun
> function isn't even being called.
>

Are you creating a standard wxWidgets application deriving a class from
wxApp, or are you implementing your own main() routine somehow? If you
derive your main class from wxApp this should work fine, or at least it
has for me.

My main class is derived from wxApp, and I override the OnInit(),
OnRun(), and OnExit() functions:

class wxMyApp : public wxApp
{
public:

virtual bool OnInit();
virtual int OnRun();
virtual int OnExit();
}

I do my initialization in the OnInit() function and return true if
everything is initialized correctly. The OnRun() function is then called
where I simply call the base class OnRun() function as I said in the
last message:

int MyApp::OnRun()
{
// run application
wxApp::OnRun();

// return my exit code
return exitCode;
}

The call to the base class wxApp::OnRun() function shouldn't return
until the application exits. I then return my own exit code. The
OnExit() function will then be called and any cleanup operations can be
performed.

If your OnRun function isn't being called then you either didn't delcare
it correctly in the wxApp derived class or you are implementing your own
main() function. I've never implemented my own main() routine using
wxWidgets, but I would imagine that the return code in this case would
be the code you return from the main() routine. If this still doesn't
help, maybe someone else on the list will have some ideas.

-Scott


Dennis Grady

unread,
Jul 6, 2005, 5:47:37 PM7/6/05
to wx-u...@lists.wxwidgets.org, Bradley Arsenault
> Ive heard that what OnExit() returns is ignored, and a possible thing
> to do with it is to be the programs exit/return code. How do i get
> around this delima?
 
You could always try:
 
IMPLEMENT_APP_NO_MAIN(MyApp)
 
int main(int argc, char** argv)
{
  wxEntry(argc, argv);
  return 0;
}
 
The good old "exit(-1);" always does the trick...albeit not as gracefully as you may like.
 

David Trancart

unread,
Jul 7, 2005, 12:12:32 PM7/7/05
to wx-u...@lists.wxwidgets.org
Hello,

I would like to use a Notebook in a dialog box with a sizer.
So i use for example

Sizer->Add(Control1...)
Sizer->Add(Notebook...)
Sizer->Add(Control2...)

1) The first problem is when i call Sizer->Layout(), i can see the first
Control and the notebook but not the second Control. Why?
2) The second problem is when i change the notebook page, the new page
have not the same size but the size of the page keep the same even if i
call Sizer()->Layout()

Do someone have a solution or example to integrate Notebook inside a sizer?

Reply all
Reply to author
Forward
0 new messages