form1.h
来自「《VC++2005编程实例》第一章的源代码」· C头文件 代码 · 共 109 行
H
109 行
#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;
using namespace Microsoft::Win32;
/// <summary>
/// Form1 摘要
///
/// 警告: 如果更改此类的名称,则需要更改
/// 与此类所依赖的所有 .resx 文件关联的托管资源编译器工具的
/// “资源文件名”属性。否则,
/// 设计器将不能与此窗体的关联
/// 本地化资源正确交互。
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: 在此处添加构造函数代码
//
}
protected:
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private:
/// <summary>
/// 必需的设计器变量。
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
this->SuspendLayout();
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackgroundImage = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"$this.BackgroundImage")));
this->ClientSize = System::Drawing::Size(390, 214);
this->Name = L"Form1";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
this->Text = L"演示在上次关闭位置启动窗体";
this->FormClosed += gcnew System::Windows::Forms::FormClosedEventHandler(this, &Form1::Form1_FormClosed);
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);
}
#pragma endregion
//读取上次窗体关闭时的位置
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
RegistryKey^ MyFirstReg;
RegistryKey^ MyReg;
MyFirstReg=Registry::CurrentUser;
try
{
MyReg=MyFirstReg->CreateSubKey("Software\\MySoft");
this->Location=Point(System::Convert::ToInt16(MyReg->GetValue("1")), System::Convert::ToInt16(MyReg->GetValue("2")));
}
catch(Exception^ MyEx)
{
}
}
//保存窗体关闭时的位置
private: System::Void Form1_FormClosed(System::Object^ sender, System::Windows::Forms::FormClosedEventArgs^ e) {
RegistryKey^ MyFirstReg;
RegistryKey^ MyReg;
MyFirstReg=Registry::CurrentUser;
MyReg=MyFirstReg->CreateSubKey("Software\\MySoft");
try
{
MyReg->SetValue("1", this->Location.X.ToString());
MyReg->SetValue("2", this->Location.Y.ToString());
}
catch (Exception^ MyEx)
{
}
}
};
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?