home *** CD-ROM | disk | FTP | other *** search
/ Delphi 4 Bible / Delphi_4_Bible_Tom_Swan_IDG_Books_1998.iso / source / OPTIONS / MAIN.PAS < prev    next >
Pascal/Delphi Source File  |  1998-03-31  |  1KB  |  77 lines

  1. unit Main;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, SysUtils, Classes, Graphics, Controls,
  7.   Forms, Dialogs, Inidata, StdCtrls, Buttons, TabNotBk,
  8.   IniFiles, ComCtrls;
  9.  
  10. type
  11.   TMainForm = class(TForm)
  12.     TabbedNotebook1: TTabbedNotebook;
  13.     CheckBox1: TCheckBox;
  14.     CheckBox2: TCheckBox;
  15.     CheckBox3: TCheckBox;
  16.     RadioButton1: TRadioButton;
  17.     RadioButton2: TRadioButton;
  18.     RadioButton3: TRadioButton;
  19.     Edit1: TEdit;
  20.     Edit2: TEdit;
  21.     BitBtn1: TBitBtn;
  22.     BitBtn2: TBitBtn;
  23.     procedure FormCreate(Sender: TObject);
  24.     procedure BitBtn1Click(Sender: TObject);
  25.   private
  26.     procedure LoadOptions;
  27.     procedure SaveOptions;
  28.   public
  29.     { Public declarations }
  30.   end;
  31.  
  32. var
  33.   MainForm: TMainForm;
  34.  
  35. implementation
  36.  
  37. {$R *.DFM}
  38.  
  39. procedure TMainForm.LoadOptions;
  40. var
  41.   IniFile: TIniFile;
  42. begin
  43.   IniFile := TIniFile.Create('test.ini');
  44.   try
  45.     LoadDataFromINI(MainForm, IniFile);
  46.   finally
  47.     IniFile.Free;
  48.   end;
  49. end;
  50.  
  51. procedure TMainForm.SaveOptions;
  52. var
  53.   IniFile: TIniFile;
  54. begin
  55.   IniFile := TIniFile.Create('test.ini');
  56.   try
  57.     SaveDataToINI(MainForm, IniFile);
  58.   finally
  59.     IniFile.Free;
  60.   end;
  61. end;
  62.  
  63. procedure TMainForm.FormCreate(Sender: TObject);
  64. begin
  65.   RegisterINIDataProp('TCheckBox', 'State');
  66.   RegisterINIDataProp('TRadioButton', 'Checked');
  67.   RegisterINIDataProp('TEdit', 'Text');
  68.   LoadOptions;
  69. end;
  70.  
  71. procedure TMainForm.BitBtn1Click(Sender: TObject);
  72. begin
  73.   SaveOptions;
  74. end;
  75.  
  76. end.
  77.