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 8798421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:05:38+00:00 2026-06-14T00:05:38+00:00

I want my code to close the current form and open another form without

  • 0

I want my code to close the current form and open another form without closing the application (in Visual C++ 2010 Express). Here’s the code I’m trying to use:

Form2^ form2=gcnew Form2();
form2->Show();
this->Close();

The application should be closed when all forms have been closed, so this->Hide() won’t work.

  • 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-14T00:05:39+00:00Added an answer on June 14, 2026 at 12:05 am

    Open the main .cpp source code file in your project, the one that contains the main() function. You’ll see a statement in that function similar to this:

    Application::Run(gcnew Form1);
    

    This overload of the Run() method will cause the program to terminate when the main form of app closes. If you want to keep it running then you’ll need to do this differently. Like using the plain Run() overload and call Application::Exit() when all of the windows are closed. You can do so by subscribing the FormClosed event, like this:

    void ExitWhenLastWindowClosed(Object^ sender, FormClosedEventArgs^ e) {
        if (Application::OpenForms->Count == 0) Application::Exit();
        else Application::OpenForms[0]->FormClosed += gcnew FormClosedEventHandler(ExitWhenLastWindowClosed);
    }
    
    [STAThreadAttribute]
    int main(array<System::String ^> ^args)
    {
        Application::EnableVisualStyles();
        Application::SetCompatibleTextRenderingDefault(false); 
        Form1^ first = gcnew Form1();
        first->FormClosed += gcnew FormClosedEventHandler(ExitWhenLastWindowClosed);
        first->Show();
        Application::Run();
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to code this part of a VB6 application in c#. How can
I want to code a simple form layout in flex. Something like the following:
i can open a form or another forms when button is clicked in netbeans.
I'm trying to make screenshots of certain forms that are open in an application.
Here is my current code: int i = 1; NSString * StockOneYahooFinance = [NSString
I want v0.1.27 of nodejs code base. This is what I did. git clone
I want code in which a div fades out if mouse does not hover
I want code to run whenever I create a new object. For example, see
i want code to check whether the user in logged in or not. I
I want code for keeping 1 second delay in Flex. i.e. i want to

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.