function InternalFindShowForm(FormClass: TFormClass; const Caption: string; Restore: Boolean): TForm; var I: Integer; begin Result := nil; for I := 0 to Screen.FormCount - 1 do begin if Screen.Forms[I] is FormClass then if (Caption = '') or (Caption = Screen.Forms[I].Caption) then begin Result := Screen.Forms[I]; Break; end; end; if Result = nil then begin Application.CreateForm(FormClass, Result); if Caption <> '' then Result.Caption := Caption; end; with Result do begin if Restore and (WindowState = wsMinimized) then WindowState := wsNormal; Show; end; end;function ShowDialog(FormClass: TFormClass): Boolean; var Dlg: TForm; begin Application.CreateForm(FormClass, Dlg); try Result := Dlg.ShowModal in [mrOk, mrYes]; finally Dlg.Free; end; end;
begin
frm.show;
end;
{sc-----------------------------------------------------------------------
+++++显示窗体函数:供内部调用。可使窗体只Create一次+++++
-----参数说明:
FormClass:窗体名
Caption: 窗体标题
Restore:显示为原来大小。
-----------------------------------------------------------------------sc}
function InternalFindShowForm(FormClass: TFormClass;
const Caption: string; Restore: Boolean): TForm;
var
I: Integer;
begin
Result := nil;
for I := 0 to Screen.FormCount - 1 do begin
if Screen.Forms[I] is FormClass then
if (Caption = '') or (Caption = Screen.Forms[I].Caption) then begin
Result := Screen.Forms[I];
Break;
end;
end;
if Result = nil then begin
Application.CreateForm(FormClass, Result);
if Caption <> '' then Result.Caption := Caption;
end;
with Result do begin
if Restore and (WindowState = wsMinimized) then WindowState := wsNormal;
Show;
end;
end;function ShowDialog(FormClass: TFormClass): Boolean;
var
Dlg: TForm;
begin
Application.CreateForm(FormClass, Dlg);
try
Result := Dlg.ShowModal in [mrOk, mrYes];
finally
Dlg.Free;
end;
end;