if not IsWindowExists('frm_spbm') then
  Application.CreateForm(Tfrm_spbm,frm_spbm);
  frm_spbm.show;
function IsWindowExists(form_1:string):boolean ;
var com_count,i:integer;
begin
    com_count:=strtoint((inttostr(Application.ComponentCount)))-1;
    for i:=0 to com_count do
    begin
        if Application.Components[i].Name=form_1 then
          break;
    end;
    if i > com_count  then
      result:=false
    else
      result:=true;
end;这样不行
  if not assigned(frm_spbm) then
  Application.CreateForm(Tfrm_spbm,frm_spbm);
  frm_spbm.show;
这样也不行,还是重复创建了,怎么回事

解决方案 »

  1.   

    窗体关闭的时候不是销毁,只是不可见吧。
    在OnClose中,将Action 设为 caFree,同时将frm_spbm 设为 nil应该可以了吧。
    然后就可以用if Assinged(frm_spbm)进行判断了。
      

  2.   

    MDI中子窗体的OnClose中加上一句才能释放:Action:=caFree;
      

  3.   

    我加了在OnClose中,将Action 设为 caFree,同时将frm_spbm 设为 nil应该可以了吧。 nil我没加
      

  4.   

    我的意思是我的窗体没有关加呀,也就是希望如果同样的窗体打开了就不需要再打开了,我都没关,应该是打开窗体时判断一下,if Assinged(frm_spbm)我也加了,没用
      

  5.   

    //这样也不行?
    if not assigned(frm_spbm) then 
      frm_spbm := Tfrm_spbm.Create(Self);
    frm_spbm.Show;