L
liq728
Unregistered / Unconfirmed
GUEST, unregistred user!
很多人都看过下面这篇文章吧,
用户在窗体上按住ALT键不放,输入“HELLO”,则会出现一个消息框,提示你激活了复
活节彩蛋,具体的彩蛋随便你设计了。下面是程序代码:注意别忘记
将窗体FORM1的KeyPreview属性设定为True。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes,Graphics, Controls, Forms, Dialogs;
type
TForm1 = class(TForm)
procedure FormKeyDown(Sender: TObject; var Key: Word;Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
keytp :string;
implementation
{$R *.DFM}
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;Shift: TShiftState);
begin
//是否按下ALT键,只接收字符
if (shift=[ssALT]) and (key >=$41) and (key <=$5A) then
begin
keytp:=keytp+chr(key);
if keytp='HELLO' then
begin
showmessage('你激活了复活节彩蛋');
end;
end;
end;
end.
但是我照着做怎么也做不出呀?有谁知道请告诉我!!
还有就是key >=$41) and (key <=$5A)是什么意思呀??
这和key=#13有什么区别??
用户在窗体上按住ALT键不放,输入“HELLO”,则会出现一个消息框,提示你激活了复
活节彩蛋,具体的彩蛋随便你设计了。下面是程序代码:注意别忘记
将窗体FORM1的KeyPreview属性设定为True。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes,Graphics, Controls, Forms, Dialogs;
type
TForm1 = class(TForm)
procedure FormKeyDown(Sender: TObject; var Key: Word;Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
keytp :string;
implementation
{$R *.DFM}
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;Shift: TShiftState);
begin
//是否按下ALT键,只接收字符
if (shift=[ssALT]) and (key >=$41) and (key <=$5A) then
begin
keytp:=keytp+chr(key);
if keytp='HELLO' then
begin
showmessage('你激活了复活节彩蛋');
end;
end;
end;
end.
但是我照着做怎么也做不出呀?有谁知道请告诉我!!
还有就是key >=$41) and (key <=$5A)是什么意思呀??
这和key=#13有什么区别??