home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1999 February
/
PCWorld_1999-02_cd.bin
/
temacd
/
HotKeys
/
hkList.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1998-10-20
|
4KB
|
159 lines
unit hkList;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, ExtCtrls, IniFiles;
type
TfrmHotkeyList = class(TForm)
pnlHotkeys: TPanel;
lvHotkeys: TListView;
procedure FormShow(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure lvHotkeysDblClick(Sender: TObject);
procedure lvHotkeysKeyPress(Sender: TObject; var Key: Char);
private
procedure PerformHotkey;
public
procedure ReadHotkeys;
{ Public declarations }
end;
var
frmHotkeyList: TfrmHotkeyList;
implementation
uses hkEdit;
{$R *.DFM}
procedure TfrmHotkeyList.ReadHotkeys;
var
Stream : TFileStream;
Reader : TReader;
Index : Integer;
Active : Boolean;
Descript,
ID,
Action,
Command,
Hotkey : String;
sVersion : String;
iVersion : Integer;
iIndex : Integer;
begin
try
Stream := TFileStream.Create(ChangeFileExt(Application.ExeName, '.hkd'), fmOpenRead);
try
Reader := TReader.Create(Stream, 4096);
try
lvHotkeys.Items.Clear;
sVersion := Reader.ReadString;
iVersion := 120;
if sVersion = 'Hotkey definitions, version 1.0' then iVersion := 100;
if sVersion = 'Hotkey definitions, version 1.05' then iVersion := 105;
Reader.ReadListBegin;
iIndex := 0;
while not Reader.EndOfList do
begin
Descript := Reader.ReadString;
if (iVersion=100) then ID := MakeID(lvHotkeys, nil, Descript) else ID := Reader.ReadString;
Index := Reader.ReadInteger;
if (iVersion=100) and (Index>1) then inc(Index);
Action := frmHotkeyEdit.cboActions.Items[Index];
case Index of
0, 1, 2: Command := Reader.ReadString;
3 : Command := frmHotkeyEdit.cboParams.Items[Reader.ReadInteger];
10 : Command := frmHotkeyEdit.cboClipboard.Items[Reader.ReadInteger];
else Command := '';
end;
Hotkey := frmHotkeyEdit.ReadHotkey(Reader);
Active := Reader.ReadBoolean;
if (Index=0) and (iVersion=120) then Reader.ReadString; // showmode
if Active then
begin
with lvHotkeys.Items.Add do
begin
Caption := Descript;
SubItems.Add(ID);
SubItems.Add(Action);
SubItems.Add(Command);
SubItems.Add(Hotkey);
SubItems.Add(IntToStr(iIndex));
inc(iIndex);
end;
end;
end;
Reader.ReadListEnd;
finally
Reader.Free;
end;
finally
Stream.Free;
end;
except
end;
end;
procedure TfrmHotkeyList.FormShow(Sender: TObject);
begin
SetWindowPos(Application.Handle, 0, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE or SWP_NOZORDER or SWP_NOACTIVATE or SWP_HIDEWINDOW);
ReadHotkeys;
end;
procedure TfrmHotkeyList.FormCreate(Sender: TObject);
var
i : integer;
begin
with TInifile.Create(ChangeFileExt(Application.ExeName, '.ini')) do
begin
Width := ReadInteger('ViewWindow', 'Width', Width);
Height := ReadInteger('ViewWindow', 'Height', Height);
for i:=0 to lvHotkeys.Columns.Count-1 do
with lvHotkeys.Columns[i] do
Width := ReadInteger('VWColumns', Caption, Width);
Free;
end;
end;
procedure TfrmHotkeyList.FormDestroy(Sender: TObject);
var
i : integer;
begin
with TInifile.Create(ChangeFileExt(Application.ExeName, '.ini')) do
begin
WriteInteger('ViewWindow', 'Width', Width);
WriteInteger('ViewWindow', 'Height', Height);
for i:=0 to lvHotkeys.Columns.Count-1 do
with lvHotkeys.Columns[i] do
WriteInteger('VWColumns', Caption, Width);
Free;
end;
end;
procedure TfrmHotkeyList.PerformHotkey;
begin
if lvHotkeys.Selected<>nil then
frmHotkeyEdit.HotkeyPressed(StrToInt(lvHotkeys.Selected.SubItems[ITEM_ACTIVE]));
end;
procedure TfrmHotkeyList.lvHotkeysDblClick(Sender: TObject);
begin
PerformHotkey;
end;
procedure TfrmHotkeyList.lvHotkeysKeyPress(Sender: TObject; var Key: Char);
begin
if Key=#13 then
begin
Key := #0;
PerformHotkey;
end;
end;
end.