这是 Winform1:
#include "Winform2.h"
#include "Winform3.h"
namespace Winform1 {
/// <summary>
/// Summary for Winform1
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
public ref class Winform1: public System::Windows::Forms::Form
{
public:
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Button^ button3;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::Button^ button4;
public:
unordered_map<int, std::string>* fb_contas_email;
Usuario* usuario;
WinForm1(Usuario* user,
unordered_map<int, std::string>* fb_contas_)
{
this->fb_contas_email = fb_contas_;
this->usuario = user;
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
this->Visible = false;
this->Close();
WinForm2 wf2(this->usuario);
wf2.ShowDialog();
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
this->Visible = false;
this->Close();
WinForm3 wf3(this->usuario);
wf3.ShowDialog();
}
//...
这是 Winform2:
#include "Winform1.h"
namespace Winform2 {
/// <summary>
/// Summary for Winform2
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
public ref class Winform2: public System::Windows::Forms::Form
{
public:
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Button^ button3;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::Button^ button4;
public:
unordered_map<int, std::string>* fb_contas_email;
Usuario* usuario;
WinForm2(Usuario* user,
unordered_map<int, std::string>* fb_contas_)
{
this->fb_contas_email = fb_contas_;
this->usuario = user;
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {
this->Visible = false;
this->Close();
WinForm1 wf1(this->usuario);
wf1.ShowDialog();
}
//...
这是 Winforms 3:
namespace Winform3 {
/// <summary>
/// Summary for Winform3
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
public ref class Winform3: public System::Windows::Forms::Form
{
public:
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Button^ button3;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::Button^ button4;
public:
unordered_map<int, std::string>* fb_contas_email;
Usuario* usuario;
WinForm3(Usuario* user,
unordered_map<int, std::string>* fb_contas_)
{
this->fb_contas_email = fb_contas_;
this->usuario = user;
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
//...
我该如何解决这个错误?我需要从 Winform1 到 Winform2 来回切换,反之亦然。但这在显示对话框时会引发未定义类的错误,这可能是因为我包含了其中包含自身的东西。但是我需要包含才能再次调用该对话框以返回。
我应该怎么办?我需要使一个对话框可见,以便在 winform1 和 winform2 之间来回切换
提前致谢