用一个按钮控制窗口的大小`````比如  点一下按钮  窗口变成 600*800的  再按一下成1024*768的  再按一下变回原始大小```````我只能按一下变了后就变不回来了````请问该怎么样实现```程序段该怎么样写````谢谢

解决方案 »

  1.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;
      sH,sW:integer;
    implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    begin
      if button1.caption='800*600' then
      begin
          form1.Width:=800;form1.Height:=600;
          button1.caption:='1024*768'; exit;
      end;
      if button1.caption='1024*768' then
      begin
          form1.Width:=1024;form1.Height:=768;
          button1.caption:='原來';exit;
      end;
      if button1.caption='原來' then
      begin
          form1.Width:=sw;form1.Height:=sh;
          button1.caption:='800*600';exit;
      end;
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
       sw:=form1.Width;sh:=form1.Height;
    end;end.
    開始設置 button1.caption:='800*600'