我有一个叫做图片搜索器的程序(我知道它很笨)。它是我的第一个 C++ 表单应用程序。我在visualbasic c ++ 2010中制作它。我有3个表格我有表格1连接到表格2但是当我尝试将表格2连接到表格3时它给了我这个错误:
1>c:\users\naqeeb\documents\visual studio\search for pictures\search for
pictures\Form2.h(143): error C2065: 'Form3' : undeclared identifier
1>c:\users\naqeeb\documents\visual studio\search for pictures\search for
pictures\Form2.h(143): error C2065: 'f3' : undeclared identifier
1>c:\users\naqeeb\documents\visual studio\search for pictures\search for
pictures\Form2.h(143): error C2061: syntax error : identifier 'Form3'
1>c:\users\naqeeb\documents\visual studio\search for pictures\search for
pictures\Form2.h(144): error C2065: 'f3' : undeclared identifier
1>c:\users\naqeeb\documents\visual studio\search for pictures\search for
pictures\Form2.h(144): error C2227: left of '->Show' must point to
class/struct/union/generic type
1> type is ''unknown-type''
1> Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
下面是 Form2 的代码:
#pragma once
#include "stdAfx.h"
#include "Form3.h"
namespace Searchforpictures {
using namespace std;
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::TextBox^ input;
protected:
protected:
private: System::Windows::Forms::Button^ search;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
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->input = (gcnew System::Windows::Forms::TextBox());
this->search = (gcnew System::Windows::Forms::Button());
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->SuspendLayout();
//
// input
//
this->input->Location = System::Drawing::Point(21, 56);
this->input->Name = L"input";
this->input->Size = System::Drawing::Size(371, 20);
this->input->TabIndex = 0;
this->input->TextChanged += gcnew System::EventHandler(this,
&Form2::textBox1_TextChanged);
//
// search
//
this->search->Enabled = false;
this->search->Location = System::Drawing::Point(432, 56);
this->search->Name = L"search";
this->search->Size = System::Drawing::Size(79, 21);
this->search->TabIndex = 1;
this->search->Text = L"Search";
this->search->UseVisualStyleBackColor = true;
this->search->Click += gcnew System::EventHandler(this,
&Form2::search_Click);
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(31, 40);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(100, 13);
this->label1->TabIndex = 2;
this->label1->Text = L"Search for a picture";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(3, 5);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(93, 13);
this->label2->TabIndex = 3;
this->label2->Text = L"Welcome Naqeeb";
//
// Form2
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(523, 109);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->search);
this->Controls->Add(this->input);
this->MaximizeBox = false;
this->MinimizeBox = false;
this->Name = L"Form2";
this->Text = L"Search for Pictures";
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void textBox1_TextChanged(System::Object^ sender,
System::EventArgs^ e) {
search->Enabled=true;
}
private: System::Void search_Click(System::Object^ sender, System::EventArgs^ e)
{
if (input->Text=="something") {
MessageBox::Show("...");
}
else if (input->Text=="sky") {
MessageBox::Show("...");
} else {
this->Hide();
Form3^ f3 = gcnew Form3();
f3->Show();
//}
}
};
}`