zoukankan      html  css  js  c++  java
  • 从上次关闭窗口的位置启动窗口

      public partial class Frm_Main : Form
        {
            public Frm_Main()
            {
                InitializeComponent();
            }
    
            private void Frm_Main_Load(object sender, EventArgs e)
            {
                RegistryKey myReg1, myReg2;//声明注册表对象
                myReg1 = Registry.CurrentUser;//获取当前用户注册表项
                try
                {
                    myReg2 = myReg1.CreateSubKey("Software\MySoft");//在注册表项中创建子项
                    this.Location = new Point(Convert.ToInt16(myReg2.GetValue("1")), Convert.ToInt16(myReg2.GetValue("2")));//设置窗体的显示位置
                }
                catch { }
            }
    
            private void Frm_Main_FormClosed(object sender, FormClosedEventArgs e)
            {
                RegistryKey myReg1, myReg2;//声明注册表对象
                myReg1 = Registry.CurrentUser;//获取当前用户注册表项
                myReg2 = myReg1.CreateSubKey("Software\MySoft");//在注册表项中创建子项
                try
                {
                    myReg2.SetValue("1", this.Location.X.ToString());//将窗体关闭位置的x坐标写入注册表
                    myReg2.SetValue("2", this.Location.Y.ToString());//将窗体关闭位置的y坐标写入注册表
                }
                catch { }
            }
        }
  • 相关阅读:
    设置CentOS7 静态获取IP
    视图与索引
    常用sql语句--DQL
    数据完整性
    常用sql语句--DML
    常用数据类型
    常用sql语句--DDL
    命令提示符内简单操作MySQL
    cnpm安装教程
    js生成指定范围的随机整数
  • 原文地址:https://www.cnblogs.com/xuekai-to-sharp/p/3557621.html
Copyright © 2011-2022 走看看