procedure TM_Form.Btn_AboutClick(sender: TObject);
begin
MessageBox(0,MB_Hint,'wofan[OCN]欢迎你',MB_ICONINFORMATION or MB_OK);
end;
procedure TM_Form.Btn_CancelClick(sender: TObject);
begin
self.Close;
end;
procedure TM_Form.Btn_OKClick(sender: TObject);
begin
RegGen;
end;
procedure TM_Form.Edt_NameChange(sender: TOBject);
Begin
RegGen;
end;
procedure TM_Form.RegGen;
var
title:string;
text:string;
HiCode:longword;
LoCode:longword;
name:string;
begin
Title:='提示';
Text:='注册名不能为空格!';
name:=Edt_Name.Text;
HiCode:=0;
LoCode:=0;
asm
push ESI
mov ESI,DWORD PTR SS:[name]
JNE @Err
XOR EAX,EAX
XOR EDI,EDI
@Cal:
mov AL,BYTE PTR DS:[ESI]
AND EAX,0FFH
TEST EAX,EAX
JE @OK
MUL AL
ADD EDI,EAX //ASCII的平方结果的累加
INC ESI
JMP @Cal
@OK:
XOR EAX,EAX
MOV EAX,EDI
XOR EDX,EDX
IMUL EAX //累加值的结果再平方
ADD EAX,EDI
ADC EDX,0
mov HiCode,EDX
mov LoCode,EAX
JMP @End
@Err:
push 0
MOV EAX,DWORD PTR SS:[Title]
PUSH EAX
MOV EAX,DWORD PTR SS:[Text]
PUSH EAX
PUSH MB_OK
Call MessageBox //提示:注册名开始字符为空,这是不允许的
@End:
End;
Edt_Code.text:=inttostr(HiCode*$100000000+LoCode);
end;
procedure TM_Form.wofanConGen;
begin
Lbl_Name:=Tlabel.Create(self);
Lbl_Code:=Tlabel.Create(self);
Lbl_wofan:=Tlabel.Create(self);
Btn_OK:=TButton.Create(self);
Btn_Cancel:=TButton.Create(self);
Btn_About:=TButton.Create(self);
Edt_Name:=TEdit.Create(self);
Edt_Code:=TEdit.Create(self);
with Lbl_Name do
Begin
Parent:=self;
left:=5;
top:=10;
caption:='注册名:';
height:=25;
width:=60;
End;
with Lbl_Code do
Begin
Parent:=self;
left:=5;
top:=35;
caption:='注册码:';
height:=25;
width:=60;
End;
with Lbl_wofan do
Begin
Parent:=self;
left:=150;
top:=90;
caption:='wofan[OCN]';
height:=25;
width:=80;
Font.color:=clred;
End;
with Edt_Name do
Begin
Parent:=self;
left:=65;
top:=5;
height:=25;
width:=160;
Text:='wofan';
AutoSelect :=false;
OnChange:=Edt_NameChange;
End;
with Edt_Code do
Begin
Parent:=self;
left:=65;
top:=30;
height:=25;
width:=160;
End;
with Btn_OK do
Begin
Parent:=self;
left:=20;
top:=60;
height:=20;
width:=60;
caption:='确定';
onClick:=Btn_OKClick;
End;
with Btn_Cancel do
Begin
Parent:=self;
left:=150;
top:=60;
height:=20;
width:=60;
caption:='退出';
Onclick:=Btn_CancelClick;
End;
with Btn_About do
Begin
Parent:=self;
left:=85;
top:=60;
height:=20;
width:=60;
caption:='关于';
Onclick:=Btn_AboutClick;
End;
end;
procedure TM_Form.wofanCreate(var Tmessage);
begin
wofanInit;
wofanConGen;
SetTimer(self.Handle ,6000,60,nil); //启动计时器
end;
procedure TM_Form.wofanDestroy(var Tmessage);
begin
KillTimer(0,6000);
end;
procedure TM_Form.wofanInit;
begin
self.Width :=240;
self.Height :=140;
self.Caption :=MB_Hint;
end;
procedure TM_Form.wofanTime(var Tmessage);
begin
if Lbl_wofan.Left<0-Lbl_wofan.Width then
Begin
Lbl_wofan.Left:=160 ; //这里只能自行设定一个值了
End
else
Begin
Lbl_wofan.Left:=Lbl_wofan.Left-2;
End;
end;