设为首页 加入收藏

TOP

用VC.NET制作WinForm应用程序(二)
2012-11-04 15:23:21 来源: 作者: 【 】 浏览:442
Tags:VC.NET 制作 WinForm 应用程序
  预备知识:

  The #using Directive-------用来将一些MC++(www.cppentry.com)使用的metadata(元数据)导入程序。如

#using <mscorlib.dll>

// 这是使用应用程序向导生成的 VC++(www.cppentry.com)

// 应用程序项目的主项目文件。

// This is the main project file for VC++(www.cppentry.com) application project

// generated using an Application Wizard.

#include "stdafx.h"

#using <mscorlib.dll>

#include <tchar.h>

#using <System.dll>

#using <System.Drawing.dll>

#using <System.Windows.Forms.dll>

#using <System.Data.dll>

using namespace System;

using namespace System::Drawing;

using namespace System::Collections;

using namespace System::ComponentModel;

using namespace System::Windows::Forms;

using namespace System::Data;

namespace myspace

{

public __gc class Form1 : public System::Windows::Forms::Form

{

private:

Button* button1;

Label* label1;

System::ComponentModel::Container* components;

public:

Form1()

{

//

// Required for Windows Form Designer support

//

components = NULL;

InitializeComponent();

//

// TODO: Add any constructor code after

// InitializeComponent call

//

}


protected:

void Dispose( bool disposing )

{

if( disposing )

{

if (components != NULL)

{

components->Dispose();

}

}

Form::Dispose( disposing );

}


private:

void InitializeComponent()

{

button1 = new Button();

label1 = new Label();

SuspendLayout();

//

// button1

//

button1->Location = Point(23, 96);

button1->Size=System::Drawing::Size(100,60);

button1->Name = "button1";

button1->TabIndex = 0;

button1->Text = "Start my first C++(www.cppentry.com) WinForm Application";

button1->Click += new System::EventHandler(this,

&Form1::button1_Click);

//

// label1

//

label1->Location = Point(150, 84);

label1->Name = "label1";

label1->TabIndex = 1;

//

// Form1

//

AutoScaleBaseSize = System::Drawing::Size(5, 13);

ClientSize = System::Drawing::Size(292, 273);

Controls->Add(label1);

Controls->Add(button1);

Name = "Form1";

Text = "Form1";

ResumeLayout(false);

}

private:

void button1_Click(Object* sender, System::EventArgs* e)

{

label1->Text = "Hello World!";

}

};

}

// This is the entry point for this application

int __stdcall WinMain()

{

Application::Run(new myspace::Form1());

return 0;

}

  我相信上面的程序大多数C++(www.cppentry.com)程序员都应该能看懂的(尤其是熟悉MFC,ATL的程序员)所以我也不必多说。

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇OpenGL下的场景层次化渲染 下一篇用VC6.0实现透明位图的自由拖动

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: