看看偶自己用的函数: function FindFormFromScreen(const sFormName: String): TCustomForm; var //通过名称查找窗体 I: Integer; begin Result := nil; for I := 0 to Screen.CustomFormCount-1 do if Screen.CustomForms[I].Name = sFormName then begin Result := Screen.CustomForms[I]; Break; end; end;
function CreateForm(const sFormName: String; AFormClass: TCustomFormClass; var AForm: TCustomForm; bShow: Boolean): Boolean; begin //创建窗体 MDIChild 不需要 AForm.Show, 即 bShow 应 = False. Result := False; AForm := FindFormFromScreen(sFormName); if AForm = nil then begin AForm := AFormClass.Create(Application); Result := True; end; if bShow and Assigned(AForm) then AForm.Show; end;