Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7872291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:09:39+00:00 2026-06-03T02:09:39+00:00

In my wxWidgets application I am checking for a command line arguement, and if

  • 0

In my wxWidgets application I am checking for a command line arguement, and if I find it, I do an action then I close the window. However, I can’t seem to get the application to close properly. I want to close the program with an exit code, such as 3. When I check for the command line parameter in wxApp::OnInit, I tried to just call exit(3), however, this seemed to be improper as it caused memory leaks somewhere within wxwidgets.

I then tried to store the exit code, override OnRun and return there, however, when I do I get a crash in init.cpp line 472 on return wxTheApp->OnRun();.

Does anyone know how I can properly close the application with a custom exit code from wxApp after detecting the application should close? I also tried to overload wxApp::OnExit, however, it never ends up being called, even when I don’t overload OnRun.

Code example at http://codepad.org/WYiOJq55 due to the code not being allowed in this post for some reason

EDIT Paste of the code:

int SomeApplication::OnRun()
{
    if(mExitCode != 0)
    {
        ExitMainLoop();
        return mExitCode;
    }
    else
        return wxApp::OnRun();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T02:09:40+00:00Added an answer on June 3, 2026 at 2:09 am

    Based upon your comments it seems that you do not ever launch a wxFrame and want to just exit an application as soon as possible. To do this, have your constructor for SomeApplication initialize mExitCode to 0. Then during OnInit do your command line argument check, and if you want to close your application immediantly after the check, set mExitCode to your exit code and return true from OnInit.

    The following is how your OnRun function would work without ever opening another window.

    int SomeApplication::OnRun()
    {
        if(mExitCode == 0)
            wxApp::OnRun();
    
        return mExitCode;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make window-base application in c++, I have listen about wxwidgets. Can
I have a command-line application written in C++ and built with gcc/make that runs
Is there a way I can read the command line arguments passed into a
Is it easy to create an IPC setup with wxWidgets? I have an application
I have created a program in Codeblocks (wxWidgets Application) I have compiled it and
I'm trying to use a custom event in my WxWidgets C++ application, like described
I created application which uses wxWidgets library using visual studio 2008. Now I would
I am writing an application based on wxWidgets library. I had some classes which
I'm making an application with wxWidgets that has a listbox in it. I want
I wrote an application using wxWidgets that uses wxList . I am having some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.