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.
#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.