这样!一个Form,两个frams在form上放一个panel和二个button,一个frames控件(放在panel上)要求:
点button1时能加载frams1,点button2时加载frams2

解决方案 »

  1.   

    动态产生就可以了unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls, ExtCtrls;type
      TForm1 = class(TForm)
        Panel1: TPanel;
        Button1: TButton;
        Button2: TButton;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementationuses Unit2, Unit3;{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
    var
      myframe1: TFrame1;
    begin
      myframe1 := TFrame1.Create(Self);
      myframe1.parent := panel1;
      myframe1.Align := alLeft;
    end;procedure TForm1.Button2Click(Sender: TObject);
    var
      myframe2: TFrame2;
    begin
      myframe2 := TFrame2.Create(Self);
      myframe2.parent := panel1;
      myframe2.Align := alRight;
    end;end.uses 
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;type
      TFrame1 = class(TFrame)
        Label1: TLabel;
      private
        { Private declarations }
      public
        { Public declarations }
      end;implementation{$R *.DFM}end.uses 
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;type
      TFrame2 = class(TFrame)
        Label1: TLabel;
      private
        { Private declarations }
      public
        { Public declarations }
      end;implementation{$R *.DFM}end.
      

  2.   

    这样frame写起来比较费劲,还不如使用隐藏,把不用的隐藏起来。
      

  3.   

    这个我也知道,关键是你怎么去调用其他的frame比如说点button1就把frame1的窗体显示在panel1,然点button2时则把窗体panel2放在panel上比如说这样一个属性My_Frame.显示窗口(frame1);
      

  4.   

    先引用容器窗体的单元,之后就可以用容器窗体.Frame2.BringToFront 了。