我在主窗体的RzGroup里添加要打开链接,点击链接后,怎样在主窗体的一个panel里打开一个子窗体

解决方案 »

  1.   

    设置窗体Parent为Panel后 ,打开子窗体会闪烁,怎么解决啊
    另外打开另外一个子窗体时,怎么关闭另一个已经打开的子窗体
      

  2.   

    窗体闪烁可以用双缓冲试试
    panel.DoubleBuffered := True;
    关闭其他的子窗体要写事件来实现
      

  3.   

    子窗口无边框
    用一form变量,记录子窗口;或者判断panel是否有子控件
      

  4.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls, StdCtrls,Unit2, Unit3;type
      TForm1 = class(TForm)
        Button1: TButton;
        Button2: TButton;
        Panel1: TPanel;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
        procedure FormClose(Sender: TObject; var Action: TCloseAction);
      private
        { Private declarations }
        ActiveForm:TForm;
        procedure ShowForm(aform:TForm;aformClass:TFormClass);
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation
    {$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    var
      form: TForm2;
    begin
      ShowForm(form,TForm2);
    end;procedure TForm1.Button2Click(Sender: TObject);
    var
      form: TForm3;
    begin
      ShowForm(form,TForm3);
    end;procedure TForm1.ShowForm(aform:TForm;aformClass:TFormClass);
    begin
      if assigned(self.ActiveForm) then self.ActiveForm.Destroy;
      aform:= aformClass.Create(owner);
      aform.Parent:= self.Panel1;
      aform.Top:=0;
      aform.Left:=0;
      aform.Show;
      self.ActiveForm:= aform;
    end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
      if assigned(activeForm) then activeForm.Destroy;
    end;end.
    form2和form3为动态创建