program Project1;uses
Forms,
Unit1 in 'Unit1.pas' {Form1};{$R *.RES}begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Form1.Top:=2;
Form1.Left:=2;
Application.Run;
end.
Forms,
Unit1 in 'Unit1.pas' {Form1};{$R *.RES}begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Form1.Top:=2;
Form1.Left:=2;
Application.Run;
end.
在Create的时候,设置窗体的top,left属性。
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if left<>100 then left:=100;
if top<>100 then top:=100;
end;
然后:
STLont: 我拉,
Form1: 我跑回100,100,
STLont: 我又拉,拉...
Form1: 我又跑回100,100, 我跑
STLont: 我又拉,拉,拉...
Form1: 我又跑回100,100, 我跑跑
STLont: 我拉。。我不玩啦! 累!
Form1: 我跑回100,100, 我跑嘿嘿! 怕了吧?
如果觉得不美观可以自己画一个,岂不是更好
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;type
TForm1 = class(TForm)
private
{ Private declarations }
procedure WMNCHitTest(var msg:TMessage);message WM_NCHITTEST;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}{ TForm1 }procedure TForm1.WMNCHitTest(var msg: TMessage);
begin
inherited;
Msg.Result:=HTCLIENT;
end;end.
TForm1 = class(TForm)
private
procedure WMPosChange(var Message: TWMWINDOWPOSCHANGING);
message WM_WINDOWPOSCHANGING; // ...........//截获并处理窗口移动时的消息,使其不可移动...
procedure Tform1.WMPosChange(var Message: TWMWINDOWPOSCHANGING);
begin
PWindowPos(TMessage(Message).lParam).Flags :=
PWindowPos(TMessage(Message).lParam).Flags or
SWP_NOMOVE or SWP_NOSIZE;
end;
STLont: 我拉,
Form1: 我跑回100,100,
STLont: 我又拉,拉...
Form1: 我又跑回100,100, 我跑
STLont: 我又拉,拉,拉...
Form1: 我又跑回100,100, 我跑跑
STLont: 我拉。。我不玩啦! 累!
Form1: 我跑回100,100, 我跑嘿嘿! 怕了吧?