有一个主窗体
在它的右边有一个BUTTON,一按这个BUTTON,就出现一个面板(这时,窗体并没有变化,只在右边多了一块出来;那个BUTTON也在这个面板上);然后一按那个BUTTON,面板又缩回主窗体中。只留下那个BUTTON部分。
*注意:这个面板与主窗体在右边,有一个“交错”区域,即在主窗体可以看见面板的一部分。思路、方法、例子

解决方案 »

  1.   

    我认为这个不是窗口吧?应该是个PANEL,如果是的话
    PANEL1.VISIBLE=NOT PANEL1.VISIBLE就可以了
      

  2.   

    你看看能不能用得上吧..unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        procedure frmMove(var Message:TWMMove);message wm_move;
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation
    uses unit2 ;
    {$R *.dfm}procedure TForm1.frmMove(var Message: TWMMove);
    var
      a:TRect;
    begin
      if not assigned(form2) then exit;
      form2.BorderStyle := Bsnone;
      form2.Height := Form1.Height div 2;
      form2.Left := Form1.Left + form1.Width -20;
      form2.Top := form1.Top +50;
      form2.SetBounds(Form1.Left + form1.Width -20,form1.top +50,200,form1.Width div 2);
      form2.Show;
      SetActiveWindow(handle);
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      form2 := tform2.Create(nil);
      form2.BorderStyle := Bsnone;
      form2.Height := Form1.Height div 2;
      form2.Left := Form1.Left + form1.Width -20;
      form2.Top := form1.Top +50;
    //  form2.Show;
    end;end.
    unit Unit2;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm2 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form2: TForm2;implementation
    uses unit1;
    {$R *.dfm}procedure TForm2.Button1Click(Sender: TObject);
    begin
      if self.Width = Button1.Width +20 then
        self.Width := Button1.Width +200  else
        self.Width := Button1.Width +20;
      setactivewindow(form1.Handle);
    end;end.
      

  3.   

    procedure TForm1.FormCreate(Sender: TObject);
    begin
      form1.BorderStyle:=bsSingle;
      Form1.Width:=644;
      panel1.Align:=alRight;
      Button1.Caption:='<';
      Button1.Height:=90;
      Button1.Width:=9;
      Button1.Top:=(height-button1.Height) div 2;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      panel1.Visible:=not panel1.Visible;
      if panel1.Visible then
      begin
      button1.Caption:='<';
      Form1.Width:=644;
      exit;
      end
      else
      Form1.Width:=418;
      button1.Caption:='>';
    end;
      

  4.   

    再来段源码
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        Panel1: TPanel;
        procedure Button1Click(Sender: TObject);
        procedure FormCreate(Sender: TObject);
        procedure FormPaint(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation
    const
      openWidth = 150;
    {$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    begin
      if panel1.Width = 20 then
      begin
        button1.Caption:='<';
        panel1.Width := 150;
      end
      else
        panel1.Width := 20;
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      form1.BorderStyle:=bsNone;
      form1.TransparentColorValue := clBlue;
      form1.TransparentColor := true;
      Button1.Caption:='<';
      Button1.Height:=90;
      Button1.Width:=9;
      Button1.Left := width -openWidth -button1.Width -20;
      Button1.Top:=(height-button1.Height) div 2;
      Panel1.BorderStyle := bsnone;
      Panel1.Width := openwidth;
      panel1.Top := (height - panel1.Height) div 2;
      panel1.Left := Button1.Left + button1.Width;
      panel1.Width := 150;
    end;procedure TForm1.FormPaint(Sender: TObject);
    begin
      canvas.Pen.Color := clblue;
      canvas.Brush.Color := clblue;
      canvas.Rectangle(width-150,0,width,height);
    end;end.