form1.cpp

来自「这是一些c++例程」· C++ 代码 · 共 55 行

CPP
55
字号
#include "stdafx.h"
#include <windows.h>

#pragma once

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

	public __gc class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
		}
  
	protected:
		void Dispose(Boolean disposing)
		{
			if (disposing && components)
			{
				components->Dispose();
			}
			__super::Dispose(disposing);
		}

	private:
		// 必需的设计器变量。
		System::ComponentModel::Container * components;

		void InitializeComponent(void)
		{
			this->Size = System::Drawing::Size(292, 273);			// 设置表单窗口大小
			this->Text = S"用托管C++开发Win表单应用程序";			// 设置表单窗口标题
			this->MaximizeBox = 0; 									// 禁止使用窗口的最大化按钮
		}	
	};
}

using namespace WinForm;

int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
	System::Threading::Thread::CurrentThread->ApartmentState = System::Threading::ApartmentState::STA;
	Application::Run(new Form1());
	return 0;
}

⌨️ 快捷键说明

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