Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Switching between forms

Status
Not open for further replies.

raydona

Programmer
May 12, 2005
27
GB
I have two Windows Forms, say, FormA and FormB. FormA, the form that loads first in Application::Run(gcnew FormA());, has button A which when clicked takes me to FormB. Similarly, FormB has button B which when clicked should take me back to FormA. The click event for A is shown below:

#include "FormB.h"
private:
static FormB^ alpha;

FormA(void)
{ InitializeComponent();
InitializeVariables(void);
}
void InitializeVariables(void)
{ alpha = nullptr;
}
private: System::Void A_Click(System::Object^ sender, System::EventArgs^ e)
{ if(alpha == nullptr)
{ alpha = gcnew FormB();
}
alpha->Show();
this->Hide();
}

FormB should look like:

#include "FormA.h"
private:
static FormA^ beta;

FormB(FormA^ x)
{ InitializeComponent();
InitializeVariables(void);
}
void InitializeVariables(void)
{ beta = x;
}
private: System::Void B_Click(System::Object^ sender, System::EventArgs^ e)
{ this->Hide();
beta->Show();
}

I get several compiler errors such as:
error C2143: syntax error : missing ';' before '^'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2065: 'beta' : undeclared identifier

How can I make the program work? I would be very grateful for all suggestions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top