だから、私は単純なフォームアプリケーションを持っています:私はフォーム1( Form1.h )と2番目のフォーム( Form2.h )を持っています。Form1 は、単純な[ユーザーの追加] ボタンで構成されています (この段階では何もしませんが、 form2 を開いて form1 を非表示にします) (この時点まで、すべてが機能します)。
しかし、form1を再度開くことになっている Form2 に「完了」ボタンを追加すると、次のエラーが発生します。 左の ->Show は、クラス/構造体/共用体/ジェネリック型を指している必要があります f1: 宣言されていない識別子 Form1: 宣言されていない識別子 して くださいヘルプ!コードは次のとおりです。
//Project Name: MultipleForms //Form1.h #ifndef FORM1_H #define FORM1_H #pragma once #include "Form2.h" namespace MultipleForms { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; /// <summary> /// Summary for Form1 /// </summary> public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); // //TODO: Add the constructor code here // } protected: /// <summary> /// Clean up any resources being used. /// </summary> ~Form1() { if (components) { delete components; } } private: System::Windows::Forms::Button^ btnAddUser; private: System::Windows::Forms::Button^ btnExit; protected: private: /// <summary> /// Required designer variable. /// </summary> System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> void InitializeComponent(void) { this->btnAddUser = (gcnew System::Windows::Forms::Button()); this->btnExit = (gcnew System::Windows::Forms::Button()); this->SuspendLayout(); // // btnAddUser // this->btnAddUser->Location = System::Drawing::Point(78, 44); this->btnAddUser->Name = L"btnAddUser"; this->btnAddUser->Size = System::Drawing::Size(75, 23); this->btnAddUser->TabIndex = 0; this->btnAddUser->Text = L"Add User"; this->btnAddUser->UseVisualStyleBackColor = true; this->btnAddUser->Click += gcnew System::EventHandler(this, &Form1::btnAddUser_Click); // // btnExit // this->btnExit->Location = System::Drawing::Point(263, 136); this->btnExit->Name = L"btnExit"; this->btnExit->Size = System::Drawing::Size(75, 23); this->btnExit->TabIndex = 1; this->btnExit->Text = L"Exit"; this->btnExit->UseVisualStyleBackColor = true; this->btnExit->Click += gcnew System::EventHandler(this, &Form1::btnExit_Click); // // Form1 // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(410, 200); this->Controls->Add(this->btnExit); this->Controls->Add(this->btnAddUser); this->Name = L"Form1"; this->Text = L"Form1"; this->ResumeLayout(false); } #pragma endregion private: System::Void btnAddUser_Click(System::Object^ sender, System::EventArgs^ e) { Form2^ f2 = gcnew Form2(); f2->Show(); this->Hide(); } private: System::Void btnExit_Click(System::Object^ sender, System::EventArgs^ e) { exit(1); } }; } #endif //Form2.h #ifndef FORM2_H #define FORM2_H #pragma once #include "Form1.h" #include<stdlib.h> namespace MultipleForms { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; /// <summary> /// Summary for Form2 /// </summary> public ref class Form2 : public System::Windows::Forms::Form { public: Form2(void) { InitializeComponent(); // //TODO: Add the constructor code here // } protected: /// <summary> /// Clean up any resources being used. /// </summary> ~Form2() { if (components) { delete components; } } private: System::Windows::Forms::Button^ btnDone; protected: protected: private: /// <summary> /// Required designer variable. /// </summary> System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> void InitializeComponent(void) { this->btnDone = (gcnew System::Windows::Forms::Button()); this->SuspendLayout(); // // btnDone // this->btnDone->Location = System::Drawing::Point(98, 110); this->btnDone->Name = L"btnDone"; this->btnDone->Size = System::Drawing::Size(75, 23); this->btnDone->TabIndex = 0; this->btnDone->Text = L"Done"; this->btnDone->UseVisualStyleBackColor = true; this->btnDone->Click += gcnew System::EventHandler(this, &Form2::btnDone_Click); // // Form2 // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(292, 273); this->Controls->Add(this->btnDone); this->Name = L"Form2"; this->Text = L"Form2"; this->ResumeLayout(false); } #pragma endregion private: System::Void btnDone_Click(System::Object^ sender, System::EventArgs^ e) { Form1^ f1 = gcnew Form1(); f1->Show(); this->Hide(); } }; } #endif
質問する
5050 次