home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2.0 - Programmer's Utilities Power Pack / Delphi 2.0 Programmer's Utilities Power Pack.iso / s_to_z / sysfile / sysopts.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-09-15  |  3.3 KB  |  111 lines

  1. {=================================================
  2.  Program: SysFile.Exe
  3.  Version: 1.0
  4.  Module: SysOpts.pas
  5.  Author: Wayne Niddery
  6.  CopyRight ⌐ 1995 Wayne Niddery and WinWright
  7.  =================================================}
  8. unit Sysopts;
  9.  
  10. {Sysopts is a very simple dialog that manages the selection of
  11.  various options for the application. It is in the AutoCreate list
  12.  as it needs to be referenced from the other dialogs to provide
  13.  current option values}
  14.  
  15. interface
  16.  
  17. uses
  18.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  19.   Forms, Dialogs, ExtCtrls, StdCtrls, Buttons;
  20.  
  21. type
  22.   TOptionsDlg = class(TForm)
  23.     Panel1: TPanel;
  24.     Bevel1: TBevel;
  25.     SaveGroup: TRadioGroup;
  26.     bOK: TBitBtn;
  27.     bCancel: TBitBtn;
  28.     DeleteGroup: TRadioGroup;
  29.     bAbout: TBitBtn;
  30.     bProtect: TBitBtn;
  31.     ckUseDrag: TCheckBox;
  32.     procedure bAboutClick(Sender: TObject);
  33.     procedure bProtectClick(Sender: TObject);
  34.     procedure FormCreate(Sender: TObject);
  35.     procedure FormDestroy(Sender: TObject);
  36.     procedure bCancelClick(Sender: TObject);
  37.     procedure DeleteGroupClick(Sender: TObject);
  38.   private
  39.     { Private declarations }
  40.   public
  41.     { Public declarations }
  42.   end;
  43.  
  44. var
  45.   OptionsDlg: TOptionsDlg;
  46.  
  47. implementation
  48.  
  49. uses
  50.   SysProt, SysAbout, SysGlb, IniFiles;
  51.  
  52. const
  53.   {string values used only within Sysopts to read and write to INI file}
  54.   iniUseDrag  = 'UseDrag';
  55.   iniSaveOpt  = 'SaveOpt';
  56.   iniDelOpt   = 'DeleteOpt';
  57.  
  58. {$R *.DFM}
  59.  
  60. procedure TOptionsDlg.FormCreate(Sender: TObject);
  61. begin
  62.   {load values from INI}
  63.   ckUseDrag.Checked := SysIni.ReadBool(iniOptions, iniUseDrag, True);
  64.   SaveGroup.ItemIndex := SysIni.ReadInteger(iniOptions, iniSaveOpt, 1);
  65.   DeleteGroup.ItemIndex := SysIni.ReadInteger(iniOptions, iniDelOpt, 1);
  66. end;
  67.  
  68. procedure TOptionsDlg.FormDestroy(Sender: TObject);
  69. begin
  70.   {write values to INI}
  71.   SysIni.WriteBool(iniOptions, iniUseDrag, ckUseDrag.Checked);
  72.   SysIni.WriteInteger(iniOptions, iniSaveOpt, SaveGroup.ItemIndex);
  73.   SysIni.WriteInteger(iniOptions, iniDelOpt, DeleteGroup.ItemIndex);
  74. end;
  75.  
  76. {handles click on About button}
  77. procedure TOptionsDlg.bAboutClick(Sender: TObject);
  78. begin
  79.   {display About box. AboutDlg is NOT in AutoCreate list for the
  80.    project, therefore it must be created before attempting to call
  81.    it and it must be destroyed afterwards}
  82.   AboutDlg := TAboutDlg.Create(Self);
  83.   AboutDlg.ShowModal; {user must close before app will continue}
  84.   AboutDlg.Release;
  85. end;
  86.  
  87. {handles click on Protect button}
  88. procedure TOptionsDlg.bProtectClick(Sender: TObject);
  89. begin
  90.   {execute ProtectDlg. user must click OK or Cancel before continuing}
  91.   ProtectDlg.ShowModal;
  92. end;
  93.  
  94. {handles cancel button}
  95. procedure TOptionsDlg.bCancelClick(Sender: TObject);
  96. begin
  97.   {restore values from INI file to erase any user changes}
  98.   ckUseDrag.Checked := SysIni.ReadBool(iniOptions, iniUseDrag, True);
  99.   SaveGroup.ItemIndex := SysIni.ReadInteger(iniOptions, iniSaveOpt, 1);
  100.   DeleteGroup.ItemIndex := SysIni.ReadInteger(iniOptions, iniDelOpt, 1);
  101. end;
  102.  
  103. {whenever any radio button in DeleteGroup is clicked, control comes here}
  104. procedure TOptionsDlg.DeleteGroupClick(Sender: TObject);
  105. begin
  106.   {inform Form1 that option has changed so it can update delete menu items}
  107.   SendMessage(Application.MainForm.Handle, wm_User + DelOptChanged, 0, 0);
  108. end;
  109.  
  110. end.
  111.