这是我用的,将tfCurrent显示在pParent内,cfcForm是tfCurrent的类,中间对pParent当前显示的Form进行了检查并释放(为减少同时打开的Form数)
procedure TfrmMAIN.DisplayForm(pParent: TPanel; cfcForm: TFormClass;
tfCurrent: TForm);
Var
i: Integer;
Temp: TControl;
begin
ShowPrompt('请等待,正在加载处理模块.....');
for i := 0 to pParent.ControlCount-1 do begin
Temp := pParent.Controls;
if ( Temp is TForm ) Then Try
If (( Temp As TForm ).Showing ) And
(( tfCurrent<>nil ) And ( Temp<>tfCurrent )) Then Begin
( Temp as TForm ).Free;
End;
except
end;
End;
If Assigned( tfCurrent ) Then
Else Application.CreateForm( cfcForm, tfCurrent );
With tfCurrent Do try
Caption := '';
BorderStyle := bsNone;
BorderIcons := [];
BringToFront;
Parent := pParent;
Align := alClient;
WindowState := wsMaximized;
Show;
except
end;
End;