马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
unit Unit2;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, Vcl.Buttons;
type
TForm2 = class(TForm)
Label1: TLabel;
Button1: TButton;
Button2: TButton;
Timer1: TTimer;
procedure Button2MouseEnter(Sender: TObject);
procedure Button1MouseEnter(Sender: TObject);
procedure Button1MouseLeave(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
Timer1: TTimer;
implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
if Button1.Caption='是的' then
MessageBox(handle,'你终于承认了','恭喜',MB_OK)
end;
procedure TForm2.Button1MouseEnter(Sender: TObject);
var temp:Integer;
begin
if Button1.Caption='不是' then
begin
temp := Random(4);
case temp of
0:
begin
if Button1.Top=85 then
Button1.Top := Button1.Top -40
else
Button1.Top := Button1.Top +40
end;
1:
begin
Button1.Enabled :=false;
end;
2:
begin
Button1.Caption :='是的';
Button2.Caption :='不是';
end;
3:
begin
Button1.Visible := false;
end;
end;
end
else
begin
Button2.Enabled := True;
Button2.Visible := True;
end;
end;
procedure TForm2.Button1MouseLeave(Sender: TObject);
begin
Button1.Enabled := true;
Button1.Visible := true;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
if Button2.Caption='是的' then
MessageBox(handle,'你终于承认了','恭喜',MB_OK)
else
MessageBox(handle,'怎么可能','-_-',MB_OK);
end;
procedure TForm2.Button2MouseEnter(Sender: TObject);
var temp:Integer;
begin
if Button2.Caption='不是' then
begin
temp := Random(4);
case temp of
0:
begin
if Button2.Top=85 then
Button2.Top := Button2.Top -40
else
Button2.Top := Button2.Top +40
end;
1:
begin
Button2.Enabled :=false;
end;
2:
begin
Button2.Caption :='是的';
Button1.Caption :='不是';
end;
3:
begin
Button2.Visible := false;
end;
end;
end
else
begin
end;
end;
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
MessageBox(handle,'关了你也是','嘿嘿',MB_OK)
end;
procedure TForm2.Timer1Timer(Sender: TObject);
begin
if ActiveControl <> nil then
ActiveControl := nil;
end;
end.
小程序下载:
http://pan.baidu.com/s/1i3gbKvN
我也是新手,刚学delphi 没多久~这个程序在网上看到这个演示图片,觉得挺有意思就自己做了一个。
代码可能有一些多余或可以精简的。也请各位大牛多指点。谢谢。
|