Hello Everybody,

Need abit of help in my code:

Basically I have two forms, namely form1 for Login and form2 is the actual application.

The first issue I had was hiding the form1(login-screen) after a successful login which I was able to do by declaring

Hide();

Now the issue is when I exit the application(form2), which I am able to but the form(login) is still running.

So, my question is could somebody please advice on how to overcome this issue?

N.B: Please P.S.A

I think I should have posted the code which was causing the problem....

This is the code in Form1.h which opens Form2.h once the credentials entered by the user is correct.........and I am able to hide Form1(login) but when I click on the exit in Form2, Form 1 is till running.....

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
	{
		// If text in textbox equals nothing, bring up message box to enter details.
	  if ( textBox1->Text->Equals( "" ) )
      {
         MessageBox::Show( "You must enter the details.", "Name Entry Error",
         MessageBoxButtons::OK, MessageBoxIcon::Exclamation );
      }
	  // If text in textbox1 and textbox2 equals correct details, 
	  // bring up form 2.
	  if ( textBox1->Text->Equals( "admin" ) & textBox2->Text->Equals( "password" ) )
      {
         MessageBox::Show( "Detail's correct.", "Correct",
         MessageBoxButtons::OK, MessageBoxIcon::Information );

		 
		Form1^ myForm1 = gcnew Form1();
		Form2^ myForm2 = gcnew Form2();

		myForm2->Show();
		myForm2->Activate();
		myForm1->Hide();
      }
	  // Any thing else bring up message box to enter correct details.
      else
      {
		 MessageBox::Show( "Enter detail's again.", "Name Entry Error",
         MessageBoxButtons::OK, MessageBoxIcon::Exclamation );
	
      }
   }

This the click event for the exit button in Form2:

private: System::Void exitToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
						// Exit the window
						 this->Close();
					 }

I am not sure on to close Form1 at the same time?

Please advice

Is it not possible to just close the other one as well?

System::Void exitToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
  // Exit both windows
  [B]myForm1->Close();[/B]
  this->Close();
}

Is it not possible to just close the other one as well?

System::Void exitToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
  // Exit both windows
  [B]myForm1->Close();[/B]
  this->Close();
}

Thanks for your reply William

I had tried the above before but didn't work. As it cant find form1.h!
I also included the Form1.h like this:

#include "Form1.h"

But still no luck