Microsoft Visual C++里制作一个Windows窗口的代码是什么?

来源:百度知道 编辑:UC知道 时间:2024/05/24 17:24:32
我是初学者,现在只会用MessageBox,要做一个Windows的窗口要怎么写呢?

Visual Studio 2005的"文件"->"新建"->"项目"中选择Windows应用程序,可以自动生成Windows的窗口。
手写的,一是不方便,二来必须把大量代码集中在一个文件中,易错且比较杂乱。

如果有兴趣的话,可以看看,手写的大致的形式如下:
//using System;
namespace TheName
{
public class Form1: System.Windows.Forms.Form
//private System.Window.Forms.Label lbl;
public Form1()
{
//Windows窗体设计器支持所必须
InitializeComponent();
//TODO:在InitializeComponent调用后添加任何构造函数代码

//清理所有正在使用的资源,程序结束时调用
protected override void Dispost(bool disposing)
{
if(disposing)
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
}

#region
//设计器支持所需的方法,不应使用编辑器修改
private void InitializeComponent()
{
//this.lbl = new System.Windows.Froms.Label();

//lbl
//this.lbl.Font