Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > .NET Frameworks (точка нет фреймворки) > Windows Forms
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 30.04.2011, 15:26   #1
cppn00b
 
Регистрация: 24.03.2011
Сообщений: 6
По умолчанию 2 формы

Помогите пожалуйста, где ошибка

123.cpp:
Код:
// 123.cpp : main project file.

#include "stdafx.h"
#include "Form1.h"
#include "Form2.h"


using namespace My123;

[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
	// Enabling Windows XP visual effects before any controls are created
	Application::EnableVisualStyles();
	Application::SetCompatibleTextRenderingDefault(false); 

	// Create the main window and run it
	Application::Run(gcnew Form1());
	return 0;
}
Form1.h:
Код:
#pragma once
#include "Form2.h"
namespace My123 {

	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^  button1;
	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->button1 = (gcnew System::Windows::Forms::Button());
			this->SuspendLayout();
			// 
			// button1
			// 
			this->button1->Location = System::Drawing::Point(58, 68);
			this->button1->Name = L"button1";
			this->button1->Size = System::Drawing::Size(161, 127);
			this->button1->TabIndex = 0;
			this->button1->Text = L"button1";
			this->button1->UseVisualStyleBackColor = true;
			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
			// 
			// Form1
			// 
			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->button1);
			this->Name = L"Form1";
			this->Text = L"Form1";
			this->ResumeLayout(false);

		}
#pragma endregion
	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
				 Form2 ^f2 = gcnew Form2();
				 f2->Show();
			 }
	};
}
Form2.h:
Код:
#pragma once
#include "Form1.h"
namespace My123 {

	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^  button1;
	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->button1 = (gcnew System::Windows::Forms::Button());
			this->SuspendLayout();
			// 
			// button1
			// 
			this->button1->Location = System::Drawing::Point(42, 56);
			this->button1->Name = L"button1";
			this->button1->Size = System::Drawing::Size(179, 117);
			this->button1->TabIndex = 0;
			this->button1->Text = L"button1";
			this->button1->UseVisualStyleBackColor = true;
			this->button1->Click += gcnew System::EventHandler(this, &Form2::button1_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->button1);
			this->Name = L"Form2";
			this->Text = L"Form2";
			this->ResumeLayout(false);

		}
#pragma endregion
	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
				 Form1 ^f1 = gcnew Form1();
				 f1->Show();
			 }
	};
}
cppn00b вне форума Ответить с цитированием
Старый 30.04.2011, 15:26   #2
cppn00b
 
Регистрация: 24.03.2011
Сообщений: 6
По умолчанию

Цитата:
Ошибка при компиляции:
1>------ Build started: Project: 123, Configuration: Debug Win32 ------
1> 123.cpp
1>c:\documents and settings\asty\desktop\123\123\Form2 .h(79): error C2065: 'Form1' : undeclared identifier
1>c:\documents and settings\asty\desktop\123\123\Form2 .h(79): error C2065: 'f1' : undeclared identifier
1>c:\documents and settings\asty\desktop\123\123\Form2 .h(79): error C2061: syntax error : identifier 'Form1'
1>c:\documents and settings\asty\desktop\123\123\Form2 .h(80): error C2065: 'f1' : undeclared identifier
1>c:\documents and settings\asty\desktop\123\123\Form2 .h(80): error C2227: left of '->Show' must point to class/struct/union/generic type
1> type is ''unknown-type''
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Если в 123.cpp поменять местами:
#include "Form2.h"
#include "Form1.h"
При компиляции получаю
Цитата:
Ошибка при компиляции:
1>------ Build started: Project: 123, Configuration: Debug Win32 ------
1> 123.cpp
1>c:\documents and settings\asty\desktop\123\123\Form1 .h(79): error C2065: 'Form2' : undeclared identifier
1>c:\documents and settings\asty\desktop\123\123\Form1 .h(79): error C2065: 'f2' : undeclared identifier
1>c:\documents and settings\asty\desktop\123\123\Form1 .h(79): error C2061: syntax error : identifier 'Form2'
1>c:\documents and settings\asty\desktop\123\123\Form1 .h(80): error C2065: 'f2' : undeclared identifier
1>c:\documents and settings\asty\desktop\123\123\Form1 .h(80): error C2227: left of '->Show' must point to class/struct/union/generic type
1> type is ''unknown-type''
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
cppn00b вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Из DBGrid одной формы отразить в ListBox на другой формы VenZell БД в Delphi 2 28.05.2010 07:27
Заголовок Child формы имеет цвет неактивной формы, хотя форма активна? PrimaryPro Общие вопросы Delphi 0 12.03.2010 11:12
как привязать размеры содержимого формы к размерам самой формы acid_bmstu Общие вопросы Delphi 4 05.02.2010 05:02
Как сделать границы формы другого цвета,формы?? Дима я Общие вопросы Delphi 3 22.06.2009 07:24
Обращение из формы в dll к элементу главной формы (delphi) a_n_n_a Помощь студентам 3 10.05.2009 04:00