(*//
标题:判断是否完成一系列按键操作
说明:示例按键彩蛋
设计:Zswang
日期:2002-01-25
支持:wjhu111@21cn.com
//*)
///////Begin Source
function IsSeriesKey(var nIndex: Integer; mShortCuts: array of TShortCut;
mShortCut: TShortCut): Boolean; { 返回是否完成一系列按键操作 }
begin
Result := False;
if (nIndex >= Low(mShortCuts)) and (nIndex <= High(mShortCuts)) then begin
if (mShortCuts[nIndex] = mShortCut) then
Inc(nIndex)
else nIndex := 0;
Result := nIndex > High(mShortCuts);
if Result then nIndex := 0;
end;
end; { IsSeriesKey }
///////End Source
///////Begin Demo
{ uses Menus }
procedure TForm1.FormCreate(Sender: TObject);
begin
KeyPreview := True;
end;
procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
{$J+}
const
vIndex: Integer = 0; //可修改类型常量(静态变量)适用Delphi6.0
{$J-}
begin
if IsSeriesKey(vIndex, [
TextToShortCut('Ctrl+z'),
TextToShortCut('Ctrl+s'),
TextToShortCut('Ctrl+w'),
TextToShortCut('Ctrl+a'),
TextToShortCut('Ctrl+n'),
TextToShortCut('Ctrl+g')],
ShortCut(Key, Shift)) then
ShowMessage('Hello World!');
end;
///////End Demo