新建工程放三个TTimer
三个TTimer中 1和3是:
Interval = 400
2是:Interval = 150
implementation
{$R *.dfm}
var
p:trect;
procedure TForm1.Timer1Timer(Sender: TObject);
var
d:tpoint;
begin
getcursorpos(d);
if p.Top<2 then
begin
if not(((d.X>p.Left) and (d.X<p.Right) and (d.Y>p.Top) and (d.y<p.Bottom)))then
begin
movewindow(self.Handle,p.Left,0-(p.Bottom-p.Top)+2,p.Right-p.Left,p.Bottom-p.Top+2,true);
form1.
timer1.Enabled:=false;
timer3.Enabled:=true;
end;
end;
end;
procedure TForm1.Timer2Timer(Sender: TObject);
begin
GetWindowRect(self.Handle,p);
end;
procedure TForm1.Timer3Timer(Sender: TObject);
var
d:tpoint;
begin
getcursorpos(d);
if ((d.X>p.Left) and (d.X<p.Right) and (d.Y>p.Top) and (d.y<p.Bottom)) then
begin
movewindow(self.Handle,p.left,-2,p.Right-p.Left,p.Bottom-p.Top,true);
SetActiveWindow(self.Handle);
timer1.Enabled:=true;
timer3.Enabled:=false;
end;
end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if p.Top<-2 then
movewindow(self.Handle,p.left,-2,p.Right-p.Left,p.Bottom-p.Top,true);
end;
end.
窗体文件内容:
object Form1: TForm1
Left = 801
Top = 87
Width = 193
Height = 505
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnMouseMove = FormMouseMove
PixelsPerInch = 96
TextHeight = 13
object Timer1: TTimer
Interval = 400
OnTimer = Timer1Timer
Left = 24
Top = 48
end
object Timer2: TTimer
Interval = 150
OnTimer = Timer2Timer
Left = 80
Top = 56
end
object Timer3: TTimer
Interval = 400
OnTimer = Timer3Timer
Left = 32
Top = 120
end
end
posted on 2009-02-01 01:03
小叶子 阅读(276)
评论(0) 编辑 收藏 引用 所属分类:
笔记