2

1-我制作了一个简单的 Windows 窗体应用程序,发现生成了这一行:

System::ComponentModel::Container ^components;

这在形式的析构函数中:

if (components)
        {
            delete components;
        }

但是,当我评论他们两个时,根本没有区别。您能否告诉我它在我的代码中的用法和/或它的用法示例?

在此先感谢,这是完整的代码..只是一个非常简单的表格,我删除了很多不必要的行,这些行指定了我的东西的绘制

#pragma once

namespace PC2newversion {

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 SignUp
/// </summary>
public ref class SignUp : public System::Windows::Forms::Form
{
public:
    SignUp(void)
    {
        InitializeComponent();
        //
        //TODO: Add the constructor code here
        //
    }

protected:
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    ~SignUp()
    {
        if (components)
        {
            delete components;
        }
    }
private: System::Windows::Forms::Label^  label8;
protected: 
private: System::Windows::Forms::TextBox^  textBox8;
private: System::Windows::Forms::TextBox^  textBox7;
private: System::Windows::Forms::Label^  label7;
private: System::Windows::Forms::Label^  label6;
private: System::Windows::Forms::TextBox^  textBox6;
private: System::Windows::Forms::Label^  label5;
private: System::Windows::Forms::TextBox^  textBox5;
private: System::Windows::Forms::Button^  button1;
private: System::Windows::Forms::TextBox^  textBox4;
private: System::Windows::Forms::TextBox^  textBox3;
private: System::Windows::Forms::TextBox^  textBox2;
private: System::Windows::Forms::TextBox^  textBox1;
private: System::Windows::Forms::Label^  label4;
private: System::Windows::Forms::Label^  label3;
private: System::Windows::Forms::Label^  label2;
private: System::Windows::Forms::Label^  label1;

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->label8 = (gcnew System::Windows::Forms::Label());
        //Deleted many unnecessary lines here

        // 
        // SignUp
        // 
        this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
        this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
        this->ClientSize = System::Drawing::Size(379, 266);
        this->Controls->Add(this->label8);
        this->Controls->Add(this->textBox8);
        this->Controls->Add(this->textBox7);
        this->Controls->Add(this->label7);
        this->Controls->Add(this->label6);
        this->Controls->Add(this->textBox6);
        this->Controls->Add(this->label5);
        this->Controls->Add(this->textBox5);
        this->Controls->Add(this->button1);
        this->Controls->Add(this->textBox4);
        this->Controls->Add(this->textBox3);
        this->Controls->Add(this->textBox2);
        this->Controls->Add(this->textBox1);
        this->Controls->Add(this->label4);
        this->Controls->Add(this->label3);
        this->Controls->Add(this->label2);
        this->Controls->Add(this->label1);
        this->Name = L"SignUp";
        this->Text = L"SignUp";
        this->ResumeLayout(false);
        this->PerformLayout();

    }
#pragma endregion
};
}

2- 在

this->Controls->...

Controls 不应该是一个变量(指针或句柄)吗?那么,它是在哪里声明的呢?

4

0 回答 0