⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.h

📁 Visual C++.NET精彩编程实例集锦 程序源代码
💻 H
字号:
#pragma once


namespace Example
{
	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> 
	/// Form1 摘要
	///
	/// 警告: 如果您更改该类的名称,则需要更改 
	///          与该类所依赖的所有 .resx 文件关联的托管资源编译器工具的 
	///          “资源文件名”属性。  否则,
	///          设计器将不能与此窗体关联的
	///          本地化资源正确交互。
	/// </summary>
	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:
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		System::ComponentModel::Container * components;

		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		void InitializeComponent(void)
		{
			System::Resources::ResourceManager *  resources = new System::Resources::ResourceManager(__typeof(Example::Form1));
			// 
			// Form1
			// 
			this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
			this->BackgroundImage = (__try_cast<System::Drawing::Image *  >(resources->GetObject(S"$this.BackgroundImage")));
			this->ClientSize = System::Drawing::Size(472, 214);
			this->MaximizeBox = false;
			this->Name = S"Form1";
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
			this->Text = S"演示创建文字形窗体";
			this->Load += new System::EventHandler(this, Form1_Load);

		}	
	private: System::Void Form1_Load(System::Object *  sender, System::EventArgs *  e)
			 {//创建文字形窗体
				 Graphics* g=this->CreateGraphics();
				 g->Clear(Color::White);
				//设定文本输出质量
				 g->set_TextRenderingHint(System::Drawing::Text::TextRenderingHint::ClearTypeGridFit);
				 g->set_SmoothingMode(System::Drawing::Drawing2D::SmoothingMode::AntiAlias);
				 FontFamily* MyFamily=new FontFamily("隶书");
				//创建路径区域
				 System::Drawing::Drawing2D::GraphicsPath* MyPath=new System::Drawing::Drawing2D::GraphicsPath();
				//向区域中追加文本
				 StringFormat* MyFormat=new StringFormat();
				 MyPath->AddString("精彩",MyFamily,(int)FontStyle::Regular,200.0f, Point(0, 30),MyFormat);
				 Pen* MyPen=new Pen(Color::Red);
				//绘制路径
				 g->DrawPath(MyPen,MyPath);
				 //从路径中构造区域
				 System::Drawing::Region* MyRegion=new System::Drawing::Region(MyPath);
				 this->Region=MyRegion;
			 }

	};
}


⌨️ 快捷键说明

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