建了两个Form,其中Form3继承了Form2,Form2背景色设为clBlue,Form3为clRed,在主Form1中有一Panel控件,设置Form2,Form3的Parent均为该Panel,显示Form2时正常,显示Form3时闪烁,不知怎么解决?
代码如下:
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;
type
  TForm1 = class(TForm)
    Button1: TButton;
    Panel1: TPanel;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
uses Unit2, Unit3;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
  if not assigned(Form3) then
    Form3 := TForm3.Create(nil);
  Form3.Parent := panel1;
  Form3.Show;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
  if not assigned(Form2) then
    Form2 := TForm2.Create(nil);
  Form2.Parent := panel1;
  Form2.Show;
end;
end.unit Unit2;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;
type
  TForm2 = class(TForm)
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form2: TForm2;
implementation
{$R *.dfm}
end.unit Unit3;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Unit2, StdCtrls;
type
  TForm3 = class(TForm2)
    Button1: TButton;
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form3: TForm3;
implementation
{$R *.dfm}
end.