home *** CD-ROM | disk | FTP | other *** search
- {=================================================
- Program: SysFile.Exe
- Version: 1.0
- Module: SysOpts.pas
- Author: Wayne Niddery
- CopyRight ⌐ 1995 Wayne Niddery and WinWright
- =================================================}
- unit Sysopts;
-
- {Sysopts is a very simple dialog that manages the selection of
- various options for the application. It is in the AutoCreate list
- as it needs to be referenced from the other dialogs to provide
- current option values}
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, ExtCtrls, StdCtrls, Buttons;
-
- type
- TOptionsDlg = class(TForm)
- Panel1: TPanel;
- Bevel1: TBevel;
- SaveGroup: TRadioGroup;
- bOK: TBitBtn;
- bCancel: TBitBtn;
- DeleteGroup: TRadioGroup;
- bAbout: TBitBtn;
- bProtect: TBitBtn;
- ckUseDrag: TCheckBox;
- procedure bAboutClick(Sender: TObject);
- procedure bProtectClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure FormDestroy(Sender: TObject);
- procedure bCancelClick(Sender: TObject);
- procedure DeleteGroupClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- OptionsDlg: TOptionsDlg;
-
- implementation
-
- uses
- SysProt, SysAbout, SysGlb, IniFiles;
-
- const
- {string values used only within Sysopts to read and write to INI file}
- iniUseDrag = 'UseDrag';
- iniSaveOpt = 'SaveOpt';
- iniDelOpt = 'DeleteOpt';
-
- {$R *.DFM}
-
- procedure TOptionsDlg.FormCreate(Sender: TObject);
- begin
- {load values from INI}
- ckUseDrag.Checked := SysIni.ReadBool(iniOptions, iniUseDrag, True);
- SaveGroup.ItemIndex := SysIni.ReadInteger(iniOptions, iniSaveOpt, 1);
- DeleteGroup.ItemIndex := SysIni.ReadInteger(iniOptions, iniDelOpt, 1);
- end;
-
- procedure TOptionsDlg.FormDestroy(Sender: TObject);
- begin
- {write values to INI}
- SysIni.WriteBool(iniOptions, iniUseDrag, ckUseDrag.Checked);
- SysIni.WriteInteger(iniOptions, iniSaveOpt, SaveGroup.ItemIndex);
- SysIni.WriteInteger(iniOptions, iniDelOpt, DeleteGroup.ItemIndex);
- end;
-
- {handles click on About button}
- procedure TOptionsDlg.bAboutClick(Sender: TObject);
- begin
- {display About box. AboutDlg is NOT in AutoCreate list for the
- project, therefore it must be created before attempting to call
- it and it must be destroyed afterwards}
- AboutDlg := TAboutDlg.Create(Self);
- AboutDlg.ShowModal; {user must close before app will continue}
- AboutDlg.Release;
- end;
-
- {handles click on Protect button}
- procedure TOptionsDlg.bProtectClick(Sender: TObject);
- begin
- {execute ProtectDlg. user must click OK or Cancel before continuing}
- ProtectDlg.ShowModal;
- end;
-
- {handles cancel button}
- procedure TOptionsDlg.bCancelClick(Sender: TObject);
- begin
- {restore values from INI file to erase any user changes}
- ckUseDrag.Checked := SysIni.ReadBool(iniOptions, iniUseDrag, True);
- SaveGroup.ItemIndex := SysIni.ReadInteger(iniOptions, iniSaveOpt, 1);
- DeleteGroup.ItemIndex := SysIni.ReadInteger(iniOptions, iniDelOpt, 1);
- end;
-
- {whenever any radio button in DeleteGroup is clicked, control comes here}
- procedure TOptionsDlg.DeleteGroupClick(Sender: TObject);
- begin
- {inform Form1 that option has changed so it can update delete menu items}
- SendMessage(Application.MainForm.Handle, wm_User + DelOptChanged, 0, 0);
- end;
-
- end.
-