这是我程序的代码,为什么不能挪动窗口?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, ExtCtrls, StdCtrls, Winsock, Clipbrd;
type
TForm1 = class(TForm)
Label1: TLabel;
Timer1: TTimer;
PopupMenu1: TPopupMenu;
IP1:TMenuItem;
N1:TMenuItem;
Label2: TLabel;
procedure IP1Click(Sender:TObject);
procedure FormCreate(Sender:TObject);
procedure Timer1Timer(Sender:TObject);
procedure N1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function LocalIP:string;
type
TaPInAddr=array[0..10] of PInAddr;
PaPInAddr=^TaPInAddr;
var
phe :PHostEnt;
pptr:PaPInAddr;
Buffer:array[0..63]of char;
I :Integer;
GInitData:TWSADATA;
begin
WSAStartup($101,GInitData);
Result:='';
GetHostName(Buffer,SizeOf(Buffer));
phe:=GetHostByName(Buffer);
if phe=nil then Exit;
pptr:=PaPInAddr(Phe^.h_addr_list);
I:=0;
while pptr^[I]<>nil do begin
result:=StrPas(inet_ntoa(pptr^[I]^));
Inc(I);
end;
WSACleanup;
end;
procedure TForm1.FormCreate(Sender:TObject);
var
FullRgn,CllientRgn,ButtonRgn:THandle;
Margin,X,Y:integer;
begin
top:=screen.Height-50;
left:=screen.Width-120;
height:=Label1.Height;
width:=Label1.Width;
Margin:=(Width-ClientWidth)div 2;
FullRgn:=CreateRectRgn(0,0,Width,Height);
X:=Margin;
Y:=Height-ClientHEight-Margin;
CllientRgn:=CreateRectRgn(X,Y,X+ClientWidth,Y+Label1.Height);
CombineRgn(FullRgn,FullRgn,CllientRgn,RGN_DIFF);
X:=X+Label1.Left;
Y:=Y+Label1.Top;
ButtonRgn:=CreateRectRgn(X,Y,X+Label1.Width,Y+Label1.Height);
CombineRgn(FullRgn,FullRgn,ButtonRgn,RGN_OR);
SetWindowRgn(Handle,FullRgn,True);
ShowWindow(Application.Handle,SW_HIDE);
SetWindowlong(Application.Handle,GWL_EXSTYLE,GetWindowLong(Application.Handle,GWL_EXSTYLE)
or WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW);
ShowWindow(Application.Handle,SW_SHOW);
end;
procedure TForm1.Timer1Timer(Sender:TObject);
begin
Timer1.Interval:=1000*100;
Label1.Caption:='IP:'+LocalIP;
end;
procedure TForm1.N1Click(Sender:TObject);
begin
application.Terminate;
end;
procedure TForm1.IP1Click(Sender:TObject);
begin
Clipboard.SetTextBuf(Pchar(copy(Label1.caption,4,255)));
end;
end.