在其private中定义一个 procedure OnResize(var msg:twmsyscommand);message WM_SYSCOMMAND;procedure TForm3.OnResize(var msg:twmsyscommand); begin //控制最大化 if msg.CmdType=SC_MAXIMIZE then begin self.Left:=0; self.Top:=0; self.Height:=form1.ClientHeight-form1.StatusBar1.Height-5; self.Width:=form1.ClientWidth-form1.TreeView1.Width-form1.Splitter1.Width-5; exit; end; //控制关闭 if msg.CmdType=SC_CLOSE then begin self.Free; exit; end; inherited; end;
你找一下是否在你的应用程序上有其它的类没有Free?
procedure TMDIChild.FormClose(Sender: TObject; var Action: TCloseAction); begin Action:=caFree; end;procedure TMDIChild.FormDestroy(Sender: TObject); begin MDIChild:=nil; end; //caFree Form被关闭,并且释放其占用的资源。
这里有一个函数,可供参考其实好多网都可下载 function TFormMain.GetLocalIP: 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 TMDIChild.FormDestroy(Sender: TObject); begin MDIChild:=nil; end;
procedure OnResize(var msg:twmsyscommand);message WM_SYSCOMMAND;procedure TForm3.OnResize(var msg:twmsyscommand);
begin
//控制最大化
if msg.CmdType=SC_MAXIMIZE then
begin
self.Left:=0;
self.Top:=0;
self.Height:=form1.ClientHeight-form1.StatusBar1.Height-5;
self.Width:=form1.ClientWidth-form1.TreeView1.Width-form1.Splitter1.Width-5;
exit;
end;
//控制关闭
if msg.CmdType=SC_CLOSE then
begin
self.Free;
exit;
end;
inherited;
end;
begin
Action:=caFree;
end;procedure TMDIChild.FormDestroy(Sender: TObject);
begin
MDIChild:=nil;
end;
//caFree Form被关闭,并且释放其占用的资源。
function TFormMain.GetLocalIP: 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;
begin
MDIChild:=nil;
end;