How to terminate the Application ? Topic is solved

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
nevinhappy
In need of some credit
In need of some credit
Posts: 1
Joined: Sun Feb 22, 2009 10:12 am

How to terminate the Application ?

Post by nevinhappy » Mon Feb 23, 2009 12:47 pm

I just use wxWidgets several days, I want to quit when I want to, I don't know how to do that,Just call 'Exit()' or through wxCloseEvent? Who can give me some tips? I will appreciate.

computerquip
Experienced Solver
Experienced Solver
Posts: 72
Joined: Fri Feb 20, 2009 7:13 pm
Location: $(#wx)\src

Post by computerquip » Mon Feb 23, 2009 1:00 pm

You should be able to call Destroy() on your current frame and that should close it by force. In my new app I've been working on out of boredom, it's very simply done:

Code: Select all

void OnClose(wxCloseEvent& event)
{
 Destroy();
}

void OnExit(wxCommandEvent& event)
{
 Destroy();
}
Don't forget to declare it inside your header.

chris_bern
Earned some good credits
Earned some good credits
Posts: 125
Joined: Wed Mar 05, 2008 3:30 pm

Post by chris_bern » Mon Feb 23, 2009 1:02 pm

Hi,

Call Destroy() on your main frame pointer, ex:

Code: Select all

frame->Destroy();
Chris

morya
Experienced Solver
Experienced Solver
Posts: 96
Joined: Fri Dec 14, 2007 2:29 am
Location: Xuzhou, China

Post by morya » Fri Feb 27, 2009 11:55 am

I think it better to use

Code: Select all

frame->Close();

BroodKiller
Knows some wx things
Knows some wx things
Posts: 49
Joined: Tue Nov 25, 2008 2:12 pm

Post by BroodKiller » Fri Feb 27, 2009 1:04 pm

An important bit to keep in mind is the program's exit code. If I recall correctly simply calling Destroy() regardless from where will more often than not result in a non-0 exit code. Not that it's of great importance, but I think that tt's better and safer to use the Close() methods.

Post Reply