其实还是要注册为Appbar,但现在没时间,如果谁弄好了,最好能贴到这上面来,后进者会感谢您的。
实现无标题移动,和粘窗口缩进功能
var
Form1: TForm1;
wlya1_formmovex ,wlya2_formmovey:integer;
wlya3_formMoving:boolean;
implementation
uses Unit2;
{$R *.DFM}
procedure TForm1.Panel1MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
begin
if form1.WindowState = wsnormal then
If Button = mbLeft then
begin
wlya1_formmovex:= X;
wlya2_formmovey:= Y;
wlya3_formMoving := True;
end;
end;
procedure TForm1.Panel1MouseMove(Sender: TObject;
Shift: TShiftState;
X, Y: Integer);
begin
If wlya3_formMoving then
begin
Self.SetBounds(Self.Left + X - wlya1_formmovex,
Self.Top + Y - wlya2_formmovey, Self.Width,Self.Height);
end;
end;
procedure TForm1.Panel1MouseUp(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
begin
If Button = mbLeft then
wlya3_formMoving := False;
if self.Top <20 then
begin
Self.SetBounds(Self.Left + X - wlya1_formmovex,
0, Self.Width,Self.Height);
timer1.Enabled :=true;
end else
timer1.Enabled :=false;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
P: TPoint;
begin
///实现窗口缩进功能wly
GetCursorPos(P);
if ((p.x>self.Left)and(p.x<(self.left+self.Width)))
and
(p.y<(self.top+self.Height))
then
begin
form1.clientWidth :=104;
form1.ClientHeight :=356;
end else
begin
form1.ClientHeight :=1;
end;
//^^^^^^^^^^^^当鼠标离开窗口范围就缩回^^^^^^^^^^^^^^^^
end;
end.