?? usetup.pas
字號:
unit uSetup;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, Buttons,Registry,uConst;
type
TFrmSetup = class(TForm)
RGSetup: TRadioGroup;
Label1: TLabel;
ListBox1: TListBox;
Label2: TLabel;
BtnAdd: TBitBtn;
BtnDelete: TBitBtn;
BtnOK: TBitBtn;
BtnEdit: TBitBtn;
procedure RGSetupClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure BtnAddClick(Sender: TObject);
procedure BtnDeleteClick(Sender: TObject);
procedure BtnEditClick(Sender: TObject);
procedure ListBox1DblClick(Sender: TObject);
procedure BtnOKClick(Sender: TObject);
private
{ Private declarations }
public
procedure GetList(Option: string;var List:TStringList);
procedure AddOption(Option,Value:string);
procedure DeleteOption(Option,Value:string);
end;
var
FrmSetup: TFrmSetup;
implementation
{$R *.DFM}
procedure TFrmSetup.GetList(Option: string;var List:TStringList);
var
MyReg:TRegistry;
begin
MyReg:=TRegistry.Create;
MyReg.RootKey:=HKEY_CURRENT_USER;
MyReg.OpenKey(GernalPath+CompanyName+'\'+SoftName+'\'+Option,True);
MyReg.GetValueNames(List);
MyReg.CloseKey;
end;
procedure TFrmSetup.AddOption(Option,Value: string);
var
MyReg:TRegistry;
begin
MyReg:=TRegistry.Create;
MyReg.RootKey:=HKEY_CURRENT_USER;
MyReg.OpenKey(GernalPath+CompanyName+'\'+SoftName+'\'+Option,True);
MyReg.WriteString(Value,'');
MyReg.CloseKey;
RgSetupClick(Self);
end;
procedure TFrmSetup.DeleteOption(Option, Value: string);
var
MyReg:TRegistry;
begin
MyReg:=TRegistry.Create;
MyReg.RootKey:=HKEY_CURRENT_USER;
MyReg.OpenKey(GernalPath+CompanyName+'\'+SoftName+'\'+Option,True);
MyReg.DeleteValue(Value);
MyReg.CloseKey;
RgSetupClick(Self);
end;
procedure TFrmSetup.RGSetupClick(Sender: TObject);
var
List:TStringList;
begin
List:=TStringList.Create;
GetList(RGSetup.Items.Strings[RGSetup.ItemIndex],List);
ListBox1.Clear;
ListBox1.Items.AddStrings(List);
List.Free;
end;
procedure TFrmSetup.FormShow(Sender: TObject);
begin
RgSetupClick(Self);
end;
procedure TFrmSetup.BtnAddClick(Sender: TObject);
var
AddValue:string;
begin
AddValue:=InputBox('輸入添加值',RGSetup.Items.Strings[RGSetup.itemindex]+'新增的值為:','');
AddOption(RGSetup.Items.Strings[RGSetup.itemindex],AddValue);
end;
procedure TFrmSetup.BtnDeleteClick(Sender: TObject);
var
Option:string;
DelStr:string;
i:integer;
begin
Option:=RGSetup.Items.Strings[RGSetup.ItemIndex];
if ListBox1.Items.Count=0 then Exit;
for i:=0 to ListBox1.Items.Count-1 do begin
if ListBox1.Selected[i] then begin
DelStr:=ListBox1.Items.Strings[i];
DeleteOption(Option,Delstr);
Exit;
end;
end;
end;
procedure TFrmSetup.BtnEditClick(Sender: TObject);
var
Option,EditStr:string;
i:integer;
EditedStr:string;
begin
EditStr:='';
Option:=RGSetup.Items.Strings[RGSetup.itemindex];
EditedStr:='';
if ListBox1.Items.Count =0 then Exit;
for i:=0 to ListBox1.Items.Count-1 do begin
if ListBox1.Selected[i] then begin
EditStr:=ListBox1.Items.Strings[i];
Break;
end;
end;
if EditStr='' then Exit;
EditedStr:=InputBox('修改值','修改'+Option+'的值為:',EditStr);
if EditedStr=EditStr then Exit
else begin
DeleteOption(Option,Editstr);
AddOption(Option,EditedStr);
end;
end;
procedure TFrmSetup.ListBox1DblClick(Sender: TObject);
begin
BtnEditClick(Self)
end;
procedure TFrmSetup.BtnOKClick(Sender: TObject);
begin
close;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -