我刚才写的。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
Procedure CMMouseLeave(var msg: TMessage); message CM_MOUSELEAVE;
Procedure CMMouseEnter(var msg: TMessage); message CM_MOUSEENTER;
public
{ Public declarations }
end;
var
Form1: TForm1;
Direction : Boolean;
implementation
{$R *.DFM}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if not Direction then
begin
Width := Width - 2;
form1.Caption := IntToStr(Width);
end
else
begin
Width := Width + 2;
form1.Caption := IntToStr(Width);
end;
if (width = 200) or (width = 120) then
begin
Timer1.Enabled := false ;
end;
end;
procedure TForm1.CMMouseLeave(var msg: TMessage);
begin
inherited;
Direction := false;
Timer1.Enabled := true;
end;
procedure TForm1.CMMouseEnter(var msg: TMessage);
begin
inherited;
Direction := true;
Timer1.Enabled := true;
end;
end.
窗体
object Form1: TForm1
Left = 4
Top = 185
BorderStyle = bsSingle
Caption = 'Form1'
ClientHeight = 348
ClientWidth = 122
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Timer1: TTimer
Enabled = False
Interval = 50
OnTimer = Timer1Timer
Left = 76
Top = 104
end
end