在一个主窗体frmmain里有个按钮button1,caption属性为‘显示窗体’
我想点一下button1,弹出frm2,同时button1的captiong属性变为'隐藏窗体'.
再点一下按钮,就隐藏frm2,button2的caption属性变为'显示窗体'

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
      if button1.Caption = 'showform' then
      begin
        Form2.Show;
        button1.Caption:= 'hideform';
      end
      else
      begin
        form2.Hide;
        button1.Caption:= 'showform'
      end;
    end;
      

  2.   

    procedure TFrmmain.Button1Click(Sender: TObject);
    begin
      if button1.Caption = '显示窗体' then
      begin
        Form2.Show;
        button1.Caption:= '隐藏窗体';
      end
      else
      begin
        form2.Hide;
        button1.Caption:= '显示窗体'
      end;
    end;