通过一个按扭Button1,show出了一个窗体form1
怎么样判断form1已经打开了?????
然后第二次,第三次....再点击Button1的时候就跳过show这个过程,直接结束!!!求助!!!!

解决方案 »

  1.   

    if  not form.showing then
        form.show;
      

  2.   

    if  not form1.showing then
        form1.show;
      

  3.   

    if assigned(form) then
    showmessage('窗体已经激活');
      

  4.   

    建议用动态创建的方法
    procedure TMainForm.N14Click(Sender: TObject);
    var
      FrmAirPortManage :TFrmAirPortManage;
    begin
      FrmAirPortManage :=TFrmAirPortManage(Application.FindComponent('FrmAirPortManage'));
      if not(Assigned(FrmAirPortManage)) then
       begin
         FrmAirPortManage :=TFrmAirPortManage.create(Application);
       end;
      FrmAirPortManage.show;end;
      

  5.   

    继承TForm,在里面加入新的构造函数,然后再构造函数内判断是否已经构造。
    class function TfTemplate.FindSelf: Boolean;
    // 寻找自身
    var
      i: Integer;
    begin
      Result := False;
      for i := 0 to Screen.FormCount - 1 do
        if Screen.Forms[i].ClassName = self.ClassName then
        begin
          Screen.Forms[i].BringToFront;
          Result := True;
          Exit;
        end;
    end;
    class procedure TfTemplate.CreateMDIChild(AOwner: TComponent);
    begin
      if not self.FindSelf then
        with Self.Create(AOwner) do
        begin
          FormStyle := fsMDIChild;
          WindowState := wsMaximized;
        end;
    end;
      

  6.   

    if Form1.visible then Exit;
    后面就写未show的代码了
      

  7.   

    除了sbwfnvnxbb的方法,其它的都OK!
    sbwfnvnxbb说的方法,每次都再运行一次show的,不行大家还有什么方法可以实现的,都来尝试一下
    不然结贴了!