procedure showform(formclass: tformclass;Fm_caption:string);//打开窗口设置标题过程 begin With FormClass.Create(application) do try if Fm_caption<>'' then caption:=Fm_caption; ShowModal; finally Free; end; end;
procedure OpenForm(FormClass: TFormClass; var fm; AOwner: TComponent);//创建子窗体(不重复创建)抄的 var i: integer; Child: TForm; begin for i := 0 to Screen.FormCount - 1 do if Screen.Forms[i].ClassType = FormClass then begin Child := Screen.Forms[i]; if Child.WindowState = wsMinimized then ShowWindow(Child.handle, SW_SHOWNORMAL) else ShowWindow(Child.handle, SW_SHOWNA); if (not Child.Visible) then Child.Visible := True; Child.BringToFront; Child.Setfocus; TForm(fm) := Child; exit; end; Child := TForm(FormClass.NewInstance); TForm(fm) := Child; Child.Create(AOwner); end;
begin
With FormClass.Create(application) do
try
if Fm_caption<>'' then
caption:=Fm_caption;
ShowModal;
finally
Free;
end;
end;
var
i: integer;
Child: TForm;
begin
for i := 0 to Screen.FormCount - 1 do
if Screen.Forms[i].ClassType = FormClass then
begin
Child := Screen.Forms[i];
if Child.WindowState = wsMinimized then
ShowWindow(Child.handle, SW_SHOWNORMAL)
else
ShowWindow(Child.handle, SW_SHOWNA);
if (not Child.Visible) then Child.Visible := True;
Child.BringToFront;
Child.Setfocus;
TForm(fm) := Child;
exit;
end;
Child := TForm(FormClass.NewInstance);
TForm(fm) := Child;
Child.Create(AOwner);
end;
借楼主宝地一用
鉴别CSDN星星的含金量http://expert.csdn.net/Expert/topic/2147/2147062.xml?temp=.9299433
procedure TMainForm.ShowForm(FormClass: TFormClass);
begin
with FormClass.Create(self) do
Try
ShowModal;
Finally
Free;
end;
end;
http://www.delphibbs.com/delphibbs/dispq.asp?lid=2106012