Form1_Load()で復元処理して、FormClosing()で保存処理する
以下はレジストリ使った例
Private Sub FormHoge_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim regkey As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\hoge\param")
Dim size As Size
size = New Size(regkey.GetValue("w", 1024), regkey.GetValue("h", 768))
Me.ClientSize = size
Dim point As Point
point = New Point(regkey.GetValue("x", 0), regkey.GetValue("y", 0))
Me.Location = point
End Sub
Private Sub FormHoge_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
Dim regkey As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\hoge\param")
regkey.SetValue("w", Me.ClientSize.Width)
regkey.SetValue("h", Me.ClientSize.Height)
regkey.SetValue("x", Me.Location.X)
regkey.SetValue("y", Me.Location.Y)
End Sub
ApplicationSettingsを使ったやつだと
DLLで実装した場合、再起動するとすべて忘れてしまった。
あとClientSizeは思ったとおりにならない罠があるらしい。