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

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using Microsoft.Win32;
    
    namespace 从上次关闭位置启动窗体
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                RegistryKey reg1, reg2;
                reg1 = Registry.CurrentUser;
                try
                {
                    reg2 = reg1.CreateSubKey("Software\Mysoft");
                    this.Location = new Point(Convert.ToInt16(reg2.GetValue("1")), Convert.ToInt16(reg2.GetValue("2")));
    
                }
                catch
                {
    
                }
            }
    
            private void Form1_FormClosed(object sender, FormClosedEventArgs e)
            {
                RegistryKey reg1, reg2;
                reg1 = Registry.CurrentUser;
                reg2 = reg1.CreateSubKey("Software\Mysoft");
    
                try
                {
                    reg2.SetValue("1", this.Location.X.ToString());
                    reg2.SetValue("2", this.Location.Y.ToString());
                }
                catch { }
            }
        }
    }
    

      

  • 相关阅读:
    Connected Graph
    Gerald and Giant Chess
    [NOI2009]诗人小G
    四边形不等式小结
    [NOI2007]货币兑换
    Cats Transport
    Cut the Sequence
    Fence
    The Battle of Chibi
    [Usaco2005 Dec]Cleaning Shifts
  • 原文地址:https://www.cnblogs.com/my-cat/p/7205609.html
Copyright © 2011-2022 走看看