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

📄 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: System::Windows::Forms::MainMenu *  mainMenu1;
	private: System::Windows::Forms::MenuItem *  menuItem1;
	private: System::Windows::Forms::MenuItem *  menuItem2;
	private: System::Windows::Forms::MenuItem *  menuItem3;
	private: System::Windows::Forms::MenuItem *  menuItem4;
	private: System::Windows::Forms::MenuItem *  menuItem5;
	private: System::Windows::Forms::MenuItem *  menuItem6;
	private: System::Windows::Forms::MenuItem *  menuItem7;
	private: System::Windows::Forms::MenuItem *  menuItem8;

	private: System::Windows::Forms::NotifyIcon *  notifyIcon1;
	private: System::Windows::Forms::ContextMenu *  contextMenu1;
	private: System::ComponentModel::IContainer *  components;

	private:
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>


		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		void InitializeComponent(void)
		{
			this->components = new System::ComponentModel::Container();
			System::Resources::ResourceManager *  resources = new System::Resources::ResourceManager(__typeof(Example::Form1));
			this->mainMenu1 = new System::Windows::Forms::MainMenu();
			this->menuItem1 = new System::Windows::Forms::MenuItem();
			this->menuItem2 = new System::Windows::Forms::MenuItem();
			this->menuItem3 = new System::Windows::Forms::MenuItem();
			this->menuItem4 = new System::Windows::Forms::MenuItem();
			this->menuItem5 = new System::Windows::Forms::MenuItem();
			this->menuItem6 = new System::Windows::Forms::MenuItem();
			this->menuItem7 = new System::Windows::Forms::MenuItem();
			this->menuItem8 = new System::Windows::Forms::MenuItem();
			this->notifyIcon1 = new System::Windows::Forms::NotifyIcon(this->components);
			this->contextMenu1 = new System::Windows::Forms::ContextMenu();
			// 
			// mainMenu1
			// 
			System::Windows::Forms::MenuItem* __mcTemp__1[] = new System::Windows::Forms::MenuItem*[1];
			__mcTemp__1[0] = this->menuItem1;
			this->mainMenu1->MenuItems->AddRange(__mcTemp__1);
			// 
			// menuItem1
			// 
			this->menuItem1->Index = 0;
			System::Windows::Forms::MenuItem* __mcTemp__2[] = new System::Windows::Forms::MenuItem*[7];
			__mcTemp__2[0] = this->menuItem2;
			__mcTemp__2[1] = this->menuItem3;
			__mcTemp__2[2] = this->menuItem4;
			__mcTemp__2[3] = this->menuItem5;
			__mcTemp__2[4] = this->menuItem6;
			__mcTemp__2[5] = this->menuItem7;
			__mcTemp__2[6] = this->menuItem8;
			this->menuItem1->MenuItems->AddRange(__mcTemp__2);
			this->menuItem1->Text = S"视图(&V)";
			// 
			// menuItem2
			// 
			this->menuItem2->Index = 0;
			this->menuItem2->Text = S"放置到托盘(&N)";
			this->menuItem2->Click += new System::EventHandler(this, menuItem2_Click);
			// 
			// menuItem3
			// 
			this->menuItem3->Index = 1;
			this->menuItem3->Text = S"-";
			// 
			// menuItem4
			// 
			this->menuItem4->Index = 2;
			this->menuItem4->Text = S"恢复正常显示(&R)";
			this->menuItem4->Click += new System::EventHandler(this, menuItem4_Click);
			// 
			// menuItem5
			// 
			this->menuItem5->Index = 3;
			this->menuItem5->Text = S"-";
			// 
			// menuItem6
			// 
			this->menuItem6->Index = 4;
			this->menuItem6->Text = S"显示托盘窗体(&T)";
			this->menuItem6->Click += new System::EventHandler(this, menuItem6_Click);
			// 
			// menuItem7
			// 
			this->menuItem7->Index = 5;
			this->menuItem7->Text = S"-";
			// 
			// menuItem8
			// 
			this->menuItem8->Index = 6;
			this->menuItem8->Text = S"关闭应用程序(&C)";
			this->menuItem8->Click += new System::EventHandler(this, menuItem8_Click);
			// 
			// notifyIcon1
			// 
			this->notifyIcon1->ContextMenu = this->contextMenu1;
			this->notifyIcon1->Icon = (__try_cast<System::Drawing::Icon *  >(resources->GetObject(S"notifyIcon1.Icon")));
			this->notifyIcon1->Text = S"这是一个演示托盘的实例程序";
			// 
			// 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(328, 206);
			this->Icon = (__try_cast<System::Drawing::Icon *  >(resources->GetObject(S"$this.Icon")));
			this->MaximizeBox = false;
			this->Menu = this->mainMenu1;
			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 menuItem2_Click(System::Object *  sender, System::EventArgs *  e)
		 {//放置到托盘
			 this->set_Visible(false);
			 this->notifyIcon1->set_Visible(true);
		 }

private: System::Void menuItem4_Click(System::Object *  sender, System::EventArgs *  e)
		 {//恢复正常显示
			 this->set_Visible(true);
			 this->notifyIcon1->set_Visible(false);
		 }

private: System::Void menuItem6_Click(System::Object *  sender, System::EventArgs *  e)
		 {//显示托盘窗体
			 this->set_Visible(true);
			 this->notifyIcon1->set_Visible(true);
		 }

private: System::Void menuItem8_Click(System::Object *  sender, System::EventArgs *  e)
		 {//关闭应用程序
			 this->Close();
		 }

private: System::Void Form1_Load(System::Object *  sender, System::EventArgs *  e)
		 {//创建托盘菜单
			 //复制“放置到托盘(N)”菜单项
			 this->contextMenu1->MenuItems->Add(this->menuItem2->CloneMenu());
			//复制分隔线菜单项
			 this->contextMenu1->MenuItems->Add(this->menuItem3->CloneMenu());
			//复制“恢复正常显示(R)”菜单项
			 this->contextMenu1->MenuItems->Add(this->menuItem4->CloneMenu());
			//复制分隔线菜单项
			 this->contextMenu1->MenuItems->Add(this->menuItem5->CloneMenu());
		 	//复制“显示托盘窗体(T)”菜单项
			 this->contextMenu1->MenuItems->Add(this->menuItem6->CloneMenu());	
	 		//复制分隔线菜单项
			 this->contextMenu1->MenuItems->Add(this->menuItem7->CloneMenu());
			 //复制“关闭应用程序(C)”菜单项
			 this->contextMenu1->MenuItems->Add(this->menuItem8->CloneMenu());
			//this.contextMenu1.MergeMenu(this.mainMenu1.);
		 }

};
}


⌨️ 快捷键说明

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