我怎么判断一个窗体已经打开了,比如我有代码:procedure TmainFM.zhiyuandanganClick(Sender: TObject);
var
  afm: TzydaFM;
begin  afm:=TzydaFM.Create(nil);
  afm.Show;end;当我已经单击过一次zhiyuandangan的时候,窗体zyda已经打开了,当我再次单击zhiyuandangan的时候他还会再打开一个!我怎么判断窗体zyda已经打开了,不再Show这个窗体了

解决方案 »

  1.   

    var
      Form1: TForm1;
      bye:Boolean ;
    implementationuses Unit2;{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    var
      afm: Tform;
    begin
    if bye then
    begin
    showmessage('该窗体已打开');
    end
    else  afm:=Form2.Create(nil);
      afm.Show;
       bye:=TRUE;
    end;
      

  2.   

    这个:  if not Assigned(CzCount_form) then
         CzCount_form:=TCzCount_form.Create(Application);
      CzCount_form.Show;
      

  3.   

    procedure TForm1.Button2Click(Sender: TObject);
    begin
      try
      if Form2.Visible then
        ShowMessage('打开')
      else
        ShowMessage('Form2已存在,但还没有打开');
      except
        ShowMessage('Form2还没有创建');
      end;
    end;
      

  4.   

    同意楼上的
    if not Assigned(CzCount_form) then
         CzCount_form:=TCzCount_form.Create(Application);
      CzCount_form.Show;
      

  5.   

    insert2003(高级打字员):
    能不能解释一下你的代码
    我很菜的,看不懂?
      

  6.   

    http://expert.csdn.net/Expert/topic/2829/2829567.xml?temp=.4974329