管一点,但在我的这个代码下无用:
procedure TForm1.OpenForm(FormClass: TFormClass; var fm; AOwner:TComponent);
var
i: integer;
Child:TForm;
begin
for i := 0 to Screen.FormCount -1 do begin
if Screen.Forms.ClassType=FormClass then begin
Child:=Screen.Forms;
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;
end;
Child:=TForm(FormClass.NewInstance);
TForm(fm):=Child;
Child.Create(AOwner);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
OpenForm(TForm2,self,self);
end;
当有其他子窗口时管用,但只有Form1时就不行了,没任何变化!WHY???