procedure OpenForm(FormClass: TFormClass; var AForm;
AOwner:TComponent=nil);
//根据窗口类名建立窗口,如果窗口存在则只激活它
var
i: integer;
Child:TForm;
begin
for i := 0 to Screen.FormCount -1 do
if Screen.Forms.ClassType=FormClass then
begin
Child:=Screen.Forms;
if Child.WindowState=wsMinimized then
Child.WindowState:=wsNormal;
Child.BringToFront;
Child.Setfocus;
TForm(AForm):=Child;
exit;
end;
Child:=TForm(FormClass.NewInstance);
TForm(AForm):=Child;
if not assigned(aowner) then aowner:=application;
Child.Create(AOwner);
end;
function ActiveForm(FormTitle:string):boolean;
//根据窗口标题激活窗口,如果窗口不存在则返回假
var
i:integer;
Child:TForm;
begin
Result:=False;
for i:=0 to screen.FormCount-1 do
begin
Child:=Screen.Forms;
if Child.caption=formtitle then
begin
Child:=Screen.Forms;
if Child.WindowState=wsminimized then
Child.WindowState:=wsnormal;
Child.BringToFront;
Child.SetFocus;
Result:=true;
end;
end;
end;