0
我有2個使用託管C++構建的獲勝形式。在按下一個按鈕時,應該從Client.h中打開另一個表單(login.h),但是我收到錯誤,如「錯誤C3673:'SenderApp :: Login':類沒有複製構造函數」。從另一個獲勝形式調用一個獲勝形式
下面是login.h代碼:
#pragma once
namespace SenderApp {
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 Login
/// </summary>
public ref class Login : public System::Windows::Forms::Form
{
public:
Login(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Login()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::TextBox^ textBox2;
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Label^ label4;
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->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->button1 = (gcnew System::Windows::Forms::Button());
this->button2 = (gcnew System::Windows::Forms::Button());
this->label4 = (gcnew System::Windows::Forms::Label());
this->SuspendLayout();
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(12, 111);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(60, 13);
this->label1->TabIndex = 0;
this->label1->Text = L"User Name";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(136, 21);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(58, 13);
this->label2->TabIndex = 1;
this->label2->Text = L"User Login";
this->label2->Click += gcnew System::EventHandler(this, &Login::label2_Click);
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(12, 157);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(53, 13);
this->label3->TabIndex = 2;
this->label3->Text = L"Password";
this->label3->Click += gcnew System::EventHandler(this, &Login::label3_Click);
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(91, 108);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(181, 20);
this->textBox1->TabIndex = 3;
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(91, 154);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(181, 20);
this->textBox2->TabIndex = 4;
this->textBox2->TextChanged += gcnew System::EventHandler(this, &Login::textBox2_TextChanged);
//
// button1
//
this->button1->Location = System::Drawing::Point(63, 212);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 5;
this->button1->Text = L"Submit";
this->button1->UseVisualStyleBackColor = true;
//
// button2
//
this->button2->Location = System::Drawing::Point(197, 212);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(75, 23);
this->button2->TabIndex = 6;
this->button2->Text = L"Cancel";
this->button2->UseVisualStyleBackColor = true;
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(12, 59);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(303, 13);
this->label4->TabIndex = 7;
this->label4->Text = L"[Please use the pre-defined logins in login.xml at C:\\Repository]";
this->label4->Click += gcnew System::EventHandler(this, &Login::label4_Click);
//
// Login
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(339, 267);
this->Controls->Add(this->label4);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Name = L"Login";
this->Text = L"Login";
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void label2_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void label3_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void textBox2_TextChanged(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void label4_Click(System::Object^ sender, System::EventArgs^ e) {
}
};
}
我想是這樣Login lgn = gcnew Login();
您需要實現複製構造函數。 – ChrisF 2011-04-28 21:15:07
但是爲什麼我只需要一個拷貝構造函數來初始化表單呢......我們在初始化其他表單時沒有定義拷貝構造函數? – 2011-04-28 21:45:52
我不確定 - 但通常Visual Studio錯誤是正確的 - 哪一行產生錯誤? – ChrisF 2011-04-29 10:38:32