2012-08-09 2 views
0

Visual C++ 프로젝트의 단추를 클릭하면 Java JOptionPane.showInputDialog처럼 작동하는 다른 양식이 열리도록 만들려고합니다. 내가 원하는 방식으로. 내가 Form21^form2=gcnew Form21(); form2->ShowDialog(); 에서 엽니 다하기 위해 노력하고있어하지만 그것이 말하는 모두 모두 잘되어야Microsoft Visual C++ 2010 다른 양식 열기

1>c:\users\steve\documents\visual studio 2010\projects\lesson 2\lesson 2\Form1.h(253): error C2065: 'Form21' : undeclared identifier 
1>c:\users\steve\documents\visual studio 2010\projects\lesson 2\lesson 2\Form1.h(253): error C2065: 'form2' : undeclared identifier 
1>c:\users\steve\documents\visual studio 2010\projects\lesson 2\lesson 2\Form1.h(253): error C2061: syntax error : identifier 'Form21' 
1>c:\users\steve\documents\visual studio 2010\projects\lesson 2\lesson 2\Form1.h(254): error C2065: 'form2' : undeclared identifier 
1>c:\users\steve\documents\visual studio 2010\projects\lesson 2\lesson 2\Form1.h(254): error C2227: left of '->ShowDialog' must point to class/struct/union/generic type 
1>   type is ''unknown-type'' 

양식 2,하지만 여기 어쨌든 그것을 위해 내가 아는

#pragma once 

namespace Lesson2 { 

    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::Label^ label1; 
    private: System::Windows::Forms::TextBox^ textBox1; 
    private: System::Windows::Forms::Label^ label2; 
    private: System::Windows::Forms::TextBox^ textBox2; 
    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->label1 = (gcnew System::Windows::Forms::Label()); 
      this->textBox1 = (gcnew System::Windows::Forms::TextBox()); 
      this->label2 = (gcnew System::Windows::Forms::Label()); 
      this->textBox2 = (gcnew System::Windows::Forms::TextBox()); 
      this->SuspendLayout(); 
      // 
      // label1 
      // 
      this->label1->AutoSize = true; 
      this->label1->Location = System::Drawing::Point(12, 9); 
      this->label1->Name = L"label1"; 
      this->label1->Size = System::Drawing::Size(61, 13); 
      this->label1->TabIndex = 0; 
      this->label1->Text = L"Username :"; 
      this->label1->Click += gcnew System::EventHandler(this, &Form2::label1_Click); 
      // 
      // textBox1 
      // 
      this->textBox1->Location = System::Drawing::Point(81, 8); 
      this->textBox1->Name = L"textBox1"; 
      this->textBox1->Size = System::Drawing::Size(108, 20); 
      this->textBox1->TabIndex = 1; 
      this->textBox1->TextChanged += gcnew System::EventHandler(this, &Form2::textBox1_TextChanged); 
      // 
      // label2 
      // 
      this->label2->AutoSize = true; 
      this->label2->Location = System::Drawing::Point(12, 54); 
      this->label2->Name = L"label2"; 
      this->label2->Size = System::Drawing::Size(59, 13); 
      this->label2->TabIndex = 2; 
      this->label2->Text = L"Password: "; 
      // 
      // textBox2 
      // 
      this->textBox2->Location = System::Drawing::Point(81, 47); 
      this->textBox2->Name = L"textBox2"; 
      this->textBox2->Size = System::Drawing::Size(108, 20); 
      this->textBox2->TabIndex = 3; 
      // 
      // Form2 
      // 
      this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); 
      this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; 
      this->ClientSize = System::Drawing::Size(211, 88); 
      this->Controls->Add(this->textBox2); 
      this->Controls->Add(this->label2); 
      this->Controls->Add(this->textBox1); 
      this->Controls->Add(this->label1); 
      this->DoubleBuffered = true; 
      this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedSingle; 
      this->MaximizeBox = false; 
      this->MinimizeBox = false; 
      this->Name = L"Form2"; 
      this->Text = L"Create an account"; 
      this->ResumeLayout(false); 
      this->PerformLayout(); 

     } 
#pragma endregion 
    private: System::Void label1_Click(System::Object^ sender, System::EventArgs^ e) { 
      } 
    private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) { 
      } 
}; 
} 

코드 자사는 교훈을 말한다 둘,하지만 그건 내가 나 자신에게 약간의 재료를 가르치기 때문이다. 나는이 물질을 진짜 쉽게 집어 들었다. 이것이 일어날 때를 제외하고. 누구든지 무슨 일이 잘못되는지 보지 않겠습니까?

+0

C++ 전문가는 아니지만 Form21에 문제가있는 것처럼 보입니다. 선언 후에 누락 된 세미콜론이있을 수 있습니까? – BlackBear

+0

Form2.h 포함 했습니까? – shf301

+0

@ shf301 예, 이미 했어요. –

답변

1

Form21은 다른 파일에서 선언 될 가능성이 높으므로 컴파일러는 Form21 유형을 찾을 수 없습니다.

Form1.h 맨 위에 #include "Form21.h" (또는 다른 경우 Form21의 클래스 선언이 들어있는 헤더 파일의 이름)을 추가하십시오.

헤더 파일과 cpp 파일 (헤더 파일에 코드가있는 것 같습니다), 전달 선언 및 C++/cli에 대한 다른 기본적인 내용을 읽어 보시기 바랍니다.

편집 : Form2 코드를 게시 한 후에는 Form21^form2=gcnew Form21();Form2^form2=gcnew Form2();이어야한다는 오류가 발생합니다. 이 아니라 Form2으로 신고했습니다.

행운을 빈다.

+0

고마워,하지만 이미 #include "Form21.h"있다. –

+0

@ The_Steve13 질문에 해당 파일의 코드를 추가 할 수 있습니까? –

+0

그래, 그럴거야. 그것의 다만 간단한 생성 된 모양 –