CÁC GIẢI PHÁP LẬP TRÌNH C# - Trang 204

204
Chương 6: Windows Form

public string RegistryPath {

get {return regPath;)

}

public string FormName {

get {return formName;}

}

public FormSettingStore(string registryPath, string formName) {

this.regPath = registryPath;

this.formName = formName;

// Tạo khóa nếu nó chưa tồn tại.

key = Registry.LocalMachine.CreateSubKey(

registryPath + formName);

}

public void SaveSettings(System.Windows.Forms.Form form) {

key.SetValue("Height", form.Height);

key.SetValue("Width", form.Width);

key.SetValue("Left", form.Left);

key.SetValue("Top", form.Top);

}

public void ApplySettings(System.Windows.Forms.Form form) {

form.Height = (int)key.GetValue("Height", form.Height);

form.Width = (int)key.GetValue("Width", form.Width);

form.Left = (int)key.GetValue("Left", form.Left);

form.Top = (int)key.GetValue("Top", form.Top);

}

}