利用一个时钟控件随时判断窗体的位置,如果窗体的top或left达到一定的位置,隐藏窗体 procedure TForm1.Timer1Timer(Sender: TObject); begin if form1.Top<=0 then form1.Top:=0-form1.Height+1; if form1.Left<=0 then form1.Left:=0-form1.Width+1; if form1.Left+form1.Width>=screen.DesktopWidth then form1.Left:=screen.DesktopWidth; end;
实现qq的自动隐藏窗口var oldwidth:integer; mousein:boolean=true; r:trect;procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if not mousein then begin width:=oldwidth; r.right:=r.Left+oldwidth; end; mousein:=true; end;procedure TForm1.FormShow(Sender: TObject); begin left:=0; oldwidth:=width; r.Left:=left; r.Top:=top; r.Right:=left+width; r.Bottom:=top+height; end;procedure TForm1.Timer1Timer(Sender: TObject); var p:tpoint; begin getcursorpos(p); if(mousein)and(not( ((p.X>=r.Left) and (p.x<=r.Right))and((p.Y>=r.Top) and (p.y<=r.Bottom)))) then begin width:=5; r.Right:=r.Left+width; mousein:=false; end; end;
代码已经测试过了 你试试var oldwidth:integer; mousein:boolean=true; r:trect;procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if not mousein then begin width:=oldwidth; r.right:=r.Left+oldwidth; end; mousein:=true; end; procedure TForm1.FormShow(Sender: TObject); begin left:=0; oldwidth:=width; r.Left:=left; r.Top:=top; r.Right:=left+width; r.Bottom:=top+height; timer1.Interval:=1; end;procedure TForm1.Timer1Timer(Sender: TObject); var p:tpoint; begin getcursorpos(p); if(mousein)and(not( ((p.X>=r.Left) and (p.x<=r.Right))and((p.Y>=r.Top) and (p.y<=r.Bottom)))) then begin width:=5; r.Right:=r.Left+width; mousein:=false; end; end; procedure TForm1.FormCreate(Sender: TObject); begin borderstyle:=bsToolWindow; end;
将top 设置为 -form1.height;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if form1.Top<=0 then
form1.Top:=0-form1.Height+1;
if form1.Left<=0 then
form1.Left:=0-form1.Width+1;
if form1.Left+form1.Width>=screen.DesktopWidth then
form1.Left:=screen.DesktopWidth;
end;
oldwidth:integer;
mousein:boolean=true;
r:trect;procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if not mousein then
begin
width:=oldwidth;
r.right:=r.Left+oldwidth;
end;
mousein:=true;
end;procedure TForm1.FormShow(Sender: TObject);
begin
left:=0;
oldwidth:=width;
r.Left:=left;
r.Top:=top;
r.Right:=left+width;
r.Bottom:=top+height;
end;procedure TForm1.Timer1Timer(Sender: TObject);
var
p:tpoint;
begin
getcursorpos(p);
if(mousein)and(not(
((p.X>=r.Left) and (p.x<=r.Right))and((p.Y>=r.Top) and (p.y<=r.Bottom)))) then
begin
width:=5;
r.Right:=r.Left+width;
mousein:=false;
end;
end;
你试试var
oldwidth:integer;
mousein:boolean=true;
r:trect;procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if not mousein then
begin
width:=oldwidth;
r.right:=r.Left+oldwidth;
end;
mousein:=true;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
left:=0;
oldwidth:=width;
r.Left:=left;
r.Top:=top;
r.Right:=left+width;
r.Bottom:=top+height;
timer1.Interval:=1;
end;procedure TForm1.Timer1Timer(Sender: TObject);
var
p:tpoint;
begin
getcursorpos(p);
if(mousein)and(not(
((p.X>=r.Left) and (p.x<=r.Right))and((p.Y>=r.Top) and (p.y<=r.Bottom)))) then
begin
width:=5;
r.Right:=r.Left+width;
mousein:=false;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
borderstyle:=bsToolWindow;
end;
DragMode: dmAutomatic
DragKind: dkDock其他的代码不知道