procedure showform(form:tformclass;newform:tform);<br><br>改成<br>procedure showform(form:tformclass;var newform:tform); <br>这个就是区别有没有var这个了,其差别是传值与传址。<br>你可以试试以下这个。<br>procedure OpenForm(FormClass: TFormClass; var fm;<br> AOwner: TComponent);<br>var<br> i: integer;<br> Child: TForm;<br>begin<br> for i := 0 to Screen.FormCount - 1 do<br> if Screen.Forms.ClassType = FormClass then<br> begin<br> Child := Screen.Forms;<br> if Child.WindowState = wsMinimized then //如已存在但最小化的窗口,将还原显示<br> ShowWindow(Child.handle, SW_SHOWNORMAL)<br> else<br> ShowWindow(Child.handle, SW_SHOWNA);<br> if (not Child.Visible) then Child.Visible := True;<br> Child.BringToFront;<br> Child.Setfocus;<br> TForm(fm) := Child;<br> exit;<br> end;<br> Child := TForm(FormClass.NewInstance);<br> TForm(fm) := Child; Child.Create(AOwner);<br>end;