从上次关闭窗口的位置启动窗口
2014-02-20 14:39
260 查看
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 { } } }
相关文章推荐
- windows应用开发由浅入深(三)利用注册表将程序启动时窗口位置设置为上次关闭的位置
- 如何在程序打开时窗口恢复上次关闭的大小和位置?
- 程序窗口按用户上次关闭时的位置大小打开程序
- ApplicationSettingsBase: 关掉WPF 窗口后,再次打开,显示在上次关闭的位置
- 从上次关闭位置启动窗体
- Android studio设置启动时不自动打开上次关闭的项目
- 关闭主窗口,启动另一个窗口
- 如何让Visual Studio 清除最近打开项目 关闭上次未关闭的标签窗口
- vim 重新打开无法回到上次关闭位置
- 设置emacs默认启动窗口位置和大小
- Ubuntu10.10修改关闭窗口按钮位置(转载)
- 利用shutdown.bat关闭Tomcat,发现进程关闭了,但是TOmcat启动窗口没关闭
- windowsclient开发--使你的client执行时记住上次关闭的大小和位置
- windows启动与关闭窗口修改
- 使用StartupInfo的参数设置窗口的启动位置的大小
- windows系统下如何在启动tomcat时,命令窗口关闭
- Window上,启动Tomcat服务之后,关闭启动窗口,服务器也随之关闭
- Qt中使用QGLview组件启动应用程序窗口自动关闭
- 用WindowFromPoint()函数来获得鼠标所在位置的窗口的句柄--发生一个关闭窗口的消息---关闭鼠标所在的窗口
- Ubuntu10.10修改关闭窗口按钮位置