hellowinforms.cpp

来自「Visual_C++[1].NET_Bible1 Visual_C++宝典书中」· C++ 代码 · 共 48 行

CPP
48
字号
// This is the main project file for VC++ application project 
// generated using an Application Wizard.

#include "stdafx.h"

#using <mscorlib.dll>
#using <System.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>

#include <tchar.h>

using namespace System;
using namespace System::ComponentModel;
using namespace System::Drawing;
using namespace System::Windows::Forms;

__gc class MyForm : public Form
{
public:
  MyForm();
protected:
  void OnClick(Object *sender, System::EventArgs* e);
};

MyForm::MyForm()
{
  Text = "My First Windows Forms Application";
  add_Click(new EventHandler(this, &MyForm::OnClick));
}

void MyForm::OnClick(Object *sender, System::EventArgs* e)
{
   MessageBox::Show("Hello, Windows Forms!");
}

int __stdcall WinMain()
{
  // Instantiate a MyForm object.
  MyForm* pMyForm = new MyForm();

  // Create and display the form and 
  // start the message loop to control messaging.
  Application::Run(pMyForm);

  return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?